eval_data=eval_data, metrics=[ "loss", "balanced_accuracy", "roc_auc", "pr_auc", "precision", "recall", "map", "ndcg" ]) print("prediction: ", wd.predict(user=1, item=2333)) print("recommendation: ", wd.recommend_user(user=1, n_rec=7)) reset_state("DeepFM") deepfm = DeepFM("ranking", data_info, embed_size=16, n_epochs=2, lr=1e-4, lr_decay=False, reg=None, batch_size=2048, num_neg=1, use_bn=False, dropout_rate=None, hidden_units="128,64,32", tf_sess_config=None) deepfm.fit(train_data, verbose=2, shuffle=True, eval_data=eval_data, metrics=[ "loss", "balanced_accuracy", "roc_auc", "pr_auc", "precision", "recall", "map", "ndcg" ]) print("prediction: ", deepfm.predict(user=1, item=2333))
train_data.build_negative_samples(data_info, num_neg=1, item_gen_mode="random", seed=2020) test_data.build_negative_samples(data_info, num_neg=1, item_gen_mode="random", seed=2222) deepfm = DeepFM("ranking", data_info, embed_size=16, n_epochs=2, lr=1e-4, lr_decay=False, reg=None, batch_size=2048, num_neg=1, use_bn=False, dropout_rate=None, hidden_units="128,64,32", tf_sess_config=None) deepfm.fit(train_data, verbose=2, shuffle=True, eval_data=test_data, metrics=[ "loss", "balanced_accuracy", "roc_auc", "pr_auc", "precision", "recall", "map", "ndcg" ], eval_batch_size=8192,
sparse_col = ["sex", "occupation", "genre1", "genre2", "genre3"] dense_col = ["age"] user_col = ["sex", "age", "occupation"] item_col = ["genre1", "genre2", "genre3"] train_data, data_info = DatasetFeat.build_trainset(train, user_col, item_col, sparse_col, dense_col, shuffle=False) test_data = DatasetFeat.build_testset(test, shuffle=False) print(data_info) train_data.build_negative_samples(data_info, num_neg=1, item_gen_mode="random", seed=2020) test_data.build_negative_samples(data_info, num_neg=1, item_gen_mode="random", seed=2222) deepfm = DeepFM("ranking", data_info, embed_size=16, n_epochs=2, lr=1e-4, lr_decay=False, reg=None, batch_size=2048, num_neg=1, use_bn=False, dropout_rate=None, hidden_units="128,64,32", tf_sess_config=None) deepfm.fit(train_data, verbose=2, shuffle=True, eval_data=test_data, metrics=["loss", "balanced_accuracy", "roc_auc", "pr_auc", "precision", "recall", "map", "ndcg"], eval_batch_size=8192, k=10, sample_user_num=2048) data_info.save(path="model_path") deepfm.save(path="model_path", model_name="deepfm_model", manual=True, inference_only=False) # ===================== load and build new data ======================== print("\n", "=" * 50, " load and build new data ", "=" * 50) tf.reset_default_graph() data_info = DataInfo.load("model_path")