Product-based Neural Networks for User Response Prediction
创新:包含一个乘积层(内积或外积),embedding特征之间进行交叉相乘
原文笔记: https://mp.weixin.qq.com/s/GMQd5RTmGPuxbokoHZs3eg
采用Criteo数据集进行测试。数据集的处理见utils
文件,主要分为:
- 考虑到Criteo文件过大,因此可以通过
read_part
和sample_sum
读取部分数据进行测试; - 对缺失数据进行填充;
- 对密集数据
I1-I13
进行归一化处理,对稀疏数据C1-C26
进行重新编码LabelEncoder
; - 整理得到
feature_columns
; - 切分数据集,最后返回
feature_columns, (train_X, train_y), (test_X, test_y)
;
class PNN(keras.Model):
def __init__(self, feature_columns, hidden_units, mode='in', dnn_dropout=0.,
activation='relu', embed_reg=1e-4, w_z_reg=1e-4, w_p_reg=1e-4, l_b_reg=1e-4):
"""
Product-based Neural Networks
:param feature_columns: A list. dense_feature_columns + sparse_feature_columns
:param hidden_units: A list. Neural network hidden units.
:param mode: A string. 'in' IPNN or 'out'OPNN.
:param activation: A string. Activation function of dnn.
:param dnn_dropout: A scalar. Dropout of dnn.
:param embed_reg: A scalar. The regularizer of embedding.
:param w_z_reg: A scalar. The regularizer of w_z_ in product layer
:param w_p_reg: A scalar. The regularizer of w_p in product layer
:param l_b_reg: A scalar. The regularizer of l_b in product layer
"""
- file:Criteo文件;
- read_part:是否读取部分数据,
True
; - sample_num:读取部分时,样本数量,
5000000
; - test_size:测试集比例,
0.2
; - embed_dim:Embedding维度,
8
; - mode:采用IPNN还是OPNN,
in
; - dnn_dropout:Dropout,
0.5
; - hidden_unit:DNN的隐藏单元,
[256, 128, 64]
; - learning_rate:学习率,
0.001
; - batch_size:
4096
; - epoch:
10
;
采用Criteo数据集中前500w
条数据,最终测试集的结果为:AUC:0.789757