def _testFunkSVD():
    model = FunkSVD(learning_rate=0.001, reg=0.005, n_epochs=100, n_factors=30)
    ratings, users, movies = load_movielen_data()

    training, testing = train_test_split(ratings)
    model.fit(training)
    model.eval(testing)
def _testExplictALS():
    model = ExplicitALS(n_factors=40, n_iters=30, reg=0.001)
    ratings, users, movies = load_movielen_data()

    training, testing = train_test_split(ratings)
    model.fit(training)
    model.eval(testing)
def _testBiasedSVD():
    bias = Bias()
    # bias = None
    model = BiasedSVD(n_iter=40, n_factor=20, bias=bias)
    ratings, users, movies = load_movielen_data()
    training, testing = train_test_split(ratings)
    model.fit(training)
    model.eval(testing)
def _testItemCF():
    bias = Bias()
    model = ItemCF(min_threshold=0.1, min_nn=1, max_nn=30, bias=bias)
    ratings, users, movies = load_movielen_data()

    training, testing = train_test_split(ratings)
    model.fit(training)
    model.eval(testing)
Beispiel #5
0
from recsys.cf.funksvd import FunkSVD
from recsys.utils.data import train_test_split, load_movielen_data
from recsys.utils.debug import LogUtil

LogUtil.configLog()
model = FunkSVD(learning_rate=0.001, reg=0.005, n_epochs=100, n_factors=30)
ratings, users, movies = load_movielen_data()

training, testing = train_test_split(ratings)
model.fit(training)
model.eval(testing)
def _testUserCF():
    model = UserCF(min_threshold=0.1, min_nn=1, max_nn=30)
    ratings, users, movies = load_movielen_data()
    training, testing = train_test_split(ratings)
    model.fit(training)
    model.eval(testing)
import sys
from recsys.utils.data import load_movielen_data, train_test_split
import numpy as np
from sklearn.feature_extraction import DictVectorizer
import tensorflow.compat.v1 as tf
tf.compat.v1.disable_eager_execution()

top = 1000
ratings, users, items = load_movielen_data()
train, test = train_test_split(ratings, frac=0.1)

train_data = [
    dict(user_id=str(row[0]), item_id=str(row[1]))
    for row in train[['user', 'item']].values
]
y_train = train['rating'].astype(np.float).values.reshape(-1, 1)

test_data = [
    dict(user_id=str(row[0]), item_id=str(row[1]))
    for row in test[['user', 'item']].values
]
y_test = test['rating'].astype(np.float).values.reshape(-1, 1)

v = DictVectorizer()
X_train = v.fit_transform(train_data)
X_test = v.transform(test_data)

X_train = X_train[:1000, :]
y_train = y_train[:1000, :]
X_train = X_train.todense()