All Projects → ChenglongChen → Tensorflow Deepfm

ChenglongChen / Tensorflow Deepfm

Licence: mit
Tensorflow implementation of DeepFM for CTR prediction.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tensorflow Deepfm

Deepctr
Easy-to-use,Modular and Extendible package of deep-learning based CTR models .
Stars: ✭ 5,686 (+200.69%)
Mutual labels:  ctr, deepfm, click-through-rate
EasyRec
A framework for large scale recommendation algorithms.
Stars: ✭ 599 (-68.32%)
Mutual labels:  ctr-prediction, deepfm
Ad Papers
Papers on Computational Advertising
Stars: ✭ 3,515 (+85.88%)
Mutual labels:  ctr-prediction
CTR-keras
Tensorflow2.x implementations of CTR(LR、FM、FFM)
Stars: ✭ 69 (-96.35%)
Mutual labels:  ctr
Recommender-System-Pytorch
基于 Pytorch 实现推荐系统相关的算法
Stars: ✭ 40 (-97.88%)
Mutual labels:  deepfm
uncertainty-calibration
A collection of research and application papers of (uncertainty) calibration techniques.
Stars: ✭ 120 (-93.65%)
Mutual labels:  ctr-prediction
DeepFM-Keras
No description or website provided.
Stars: ✭ 28 (-98.52%)
Mutual labels:  deepfm
FSCNMF
An implementation of "Fusing Structure and Content via Non-negative Matrix Factorization for Embedding Information Networks".
Stars: ✭ 16 (-99.15%)
Mutual labels:  factorization-machine
BARS
Towards open benchmarking for recommender systems https://openbenchmark.github.io/BARS
Stars: ✭ 157 (-91.7%)
Mutual labels:  ctr-prediction
DeepLight Deep-Lightweight-Feature-Interactions
Accelerating Inference for Recommendation Systems (WSDM'21)
Stars: ✭ 100 (-94.71%)
Mutual labels:  factorization-machine
Awesome-Machine-Learning-Papers
📖Notes and remarks on Machine Learning related papers
Stars: ✭ 35 (-98.15%)
Mutual labels:  ctr-prediction
click-through-rate-prediction
📈 Click-Through Rate Prediction using Logistic Regression and Tree Algorithms
Stars: ✭ 60 (-96.83%)
Mutual labels:  click-through-rate
Tencent Social Ads2018
2018腾讯社交广告33名;
Stars: ✭ 22 (-98.84%)
Mutual labels:  ctr
CTR-tools
Crash Team Racing (PS1) tools - a C# framework by DCxDemo and a set of tools to parse files found in the original kart racing game by Naughty Dog.
Stars: ✭ 93 (-95.08%)
Mutual labels:  ctr
FactorizationMachine
implementation of factorization machine, support classification.
Stars: ✭ 19 (-99%)
Mutual labels:  factorization-machine
din
keras implementation about Deep Interest Network
Stars: ✭ 57 (-96.99%)
Mutual labels:  ctr
Neural-Factorization-Machine
Factorization Machine, Deep Learning, Recommender System
Stars: ✭ 20 (-98.94%)
Mutual labels:  factorization-machine
crypto
🔐 Fastest crypto library for Deno written in pure Typescript. AES, Blowfish, CAST5, DES, 3DES, HMAC, HKDF, PBKDF2
Stars: ✭ 40 (-97.88%)
Mutual labels:  ctr
recommendation model
练习下用pytorch来复现下经典的推荐系统模型, 如MF, FM, DeepConn, MMOE, PLE, DeepFM, NFM, DCN, AFM, AutoInt, ONN, FiBiNET, DCN-v2, AFN, DCAP等
Stars: ✭ 286 (-84.88%)
Mutual labels:  deepfm
ai explore
机器学习、深度学习基础知识. 推荐系统及nlp相关算法实现
Stars: ✭ 54 (-97.14%)
Mutual labels:  ctr-prediction

tensorflow-DeepFM

This project includes a Tensorflow implementation of DeepFM [1].

NEWS

Usage

Input Format

This implementation requires the input data in the following format:

  • Xi: [[ind1_1, ind1_2, ...], [ind2_1, ind2_2, ...], ..., [indi_1, indi_2, ..., indi_j, ...], ...]
    • indi_j is the feature index of feature field j of sample i in the dataset
  • Xv: [[val1_1, val1_2, ...], [val2_1, val2_2, ...], ..., [vali_1, vali_2, ..., vali_j, ...], ...]
    • vali_j is the feature value of feature field j of sample i in the dataset
    • vali_j can be either binary (1/0, for binary/categorical features) or float (e.g., 10.24, for numerical features)
  • y: target of each sample in the dataset (1/0 for classification, numeric number for regression)

Please see example/DataReader.py an example how to prepare the data in required format for DeepFM.

Init and train a model

import tensorflow as tf
from sklearn.metrics import roc_auc_score

# params
dfm_params = {
    "use_fm": True,
    "use_deep": True,
    "embedding_size": 8,
    "dropout_fm": [1.0, 1.0],
    "deep_layers": [32, 32],
    "dropout_deep": [0.5, 0.5, 0.5],
    "deep_layers_activation": tf.nn.relu,
    "epoch": 30,
    "batch_size": 1024,
    "learning_rate": 0.001,
    "optimizer_type": "adam",
    "batch_norm": 1,
    "batch_norm_decay": 0.995,
    "l2_reg": 0.01,
    "verbose": True,
    "eval_metric": roc_auc_score,
    "random_seed": 2017
}

# prepare training and validation data in the required format
Xi_train, Xv_train, y_train = prepare(...)
Xi_valid, Xv_valid, y_valid = prepare(...)

# init a DeepFM model
dfm = DeepFM(**dfm_params)

# fit a DeepFM model
dfm.fit(Xi_train, Xv_train, y_train)

# make prediction
dfm.predict(Xi_valid, Xv_valid)

# evaluate a trained model
dfm.evaluate(Xi_valid, Xv_valid, y_valid)

You can use early_stopping in the training as follow

dfm.fit(Xi_train, Xv_train, y_train, Xi_valid, Xv_valid, y_valid, early_stopping=True)

You can refit the model on the whole training and validation set as follow

dfm.fit(Xi_train, Xv_train, y_train, Xi_valid, Xv_valid, y_valid, early_stopping=True, refit=True)

You can use the FM or DNN part only by setting the parameter use_fm or use_dnn to False.

Regression

This implementation also supports regression task. To use DeepFM for regression, you can set loss_type as mse. Accordingly, you should use eval_metric for regression, e.g., mse or mae.

Example

Folder example includes an example usage of DeepFM/FM/DNN models for Porto Seguro's Safe Driver Prediction competition on Kaggle.

Please download the data from the competition website and put them into the example/data folder.

To train DeepFM model for this dataset, run

$ cd example
$ python main.py

Please see example/DataReader.py how to parse the raw dataset into the required format for DeepFM.

Performance

DeepFM

dfm

FM

fm

DNN

dnn

Some tips

  • You should tune the parameters for each model in order to get reasonable performance.
  • You can also try to ensemble these models or ensemble them with other models (e.g., XGBoost or LightGBM).

Reference

[1] DeepFM: A Factorization-Machine based Neural Network for CTR Prediction, Huifeng Guo, Ruiming Tang, Yunming Yey, Zhenguo Li, Xiuqiang He.

Acknowledgments

This project gets inspirations from the following projects:

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].