<jupyter_start><jupyter_text>FunkSVD Recommender example Let's load the modules and data first<jupyter_code>from recsys.recommender import FunkSVD
from recsys.datasets import loadMovieLens100k
from recsys.metrics import rmse

import warnings
warnings.filterwarnings('ignore')

# load the movielens data, we can only use the userid, itemid and rating information in SVD, so we don't need all the columns.
train, test, _, _ = loadMovieLens100k(train_test_split=True)

print(train.head())<jupyter_output>userId  itemId  rating
0       1       1       5
1       1       2       3
2       1       3       4
3       1       4       3
4       1       5       3<jupyter_text>Now let's train the model with the train data<jupyter_code>f = FunkSVD(k=64, learning_rate=0.006, regularizer = 0.2, iterations = 5, method = 'stochastic', bias=True)
f.fit(X=train, formatizer={'user':'userId', 'item':'itemId', 'value':'rating'},verbose=True)<jupyter_output>Epoch 0: Error: 0.844157454663562
Epoch 1: Error: 0.7822681848331058
Epoch 2: Error: 0.7654319700355098
Epoch 3: Error: 0.7573448651613245
Epoch 4: Error: 0.75247303056629<jupyter_text>Now let's use the trained model to predict ratings on the test set.<jupyter_code>preds = f.predict(test, formatizer={'user':'userId', 'item':'itemId'})
error = rmse(preds, test['rating'])
print(error)<jupyter_output>0.9749666307888072
{'fraction_non_alphanumeric': 0.10286554004408523, 'fraction_numerical': 0.10213078618662748, 'mean_word_length': 4.362204724409449, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '337774', 'license': 'MIT', 'n_tokens_mistral': 565, 'n_tokens_neox': 482, 'n_words': 132, 'path': 'examples/FunkSVD_example.ipynb', 'repo_name': 'shenghuiliuu/recsys', 'size': '1361'}