tffm レコメンド性能高そう
$ pip install tffm
order とかよく挙動がわからない。パラメータがあるけど。 この辺、レコメンドエンジンに使えそう。
from sklearn.model_selection import train_test_split X_tr, X_te, y_tr, y_te = train_test_split(df.values, df['tfidf'].values, random_state=42, test_size=0.3) from tffm import TFFMRegressor from sklearn.metrics import mean_squared_error order = 3 model = TFFMRegressor( order=order, rank=10, optimizer=tf.train.AdamOptimizer(learning_rate=0.001), n_epochs=50, batch_size=1024, init_std=0.001, reg=0.01, input_type='sparse' ) # translate Y from {0,1} to {-10, 10} model.fit(X_tr_sparse, y_tr, show_progress=True) predictions = model.predict(X_te_sparse) import scipy.sparse as sp # only CSR format supported X_tr_sparse = sp.csr_matrix(X_tr) X_te_sparse = sp.csr_matrix(X_te) from sklearn.metrics import roc_auc_score, accuracy_score print('MSE: {}'.format(mean_squared_error(y_te, predictions)))