Path: blob/main/Lessons/Lesson 14 - RecSys 2/resources/Hybrid Recommender.ipynb
871 views
Kernel: Python 3 (system-wide)
Hybrid Recommenders
In [1]:
We aren't able to include the file for the next cell because it is 1gb and too large for Github and possibly too large for CoCalc. If you want to play with this code you'll have to download this file from the link in Banik's textbook.
In [2]:
In [3]:
Out[3]:
In [4]:
In [5]:
Out[5]:
In [6]:
Out[6]:
0
Toy Story 0
Jumanji 1
Grumpier Old Men 2
Waiting to Exhale 3
Father of the Bride Part II 4
Name: 1, dtype: int64
Note: The surprise package changed a bit since the book was published. The code to train a model using cross validation has changed a bit as shown below. Also, notice that we aren't splitting the data into test and training and testing sets, rather we're using the whole dataset for illustration.
In [7]:
Out[7]:
Evaluating RMSE, MAE of algorithm SVD on 5 split(s).
Fold 1 Fold 2 Fold 3 Fold 4 Fold 5 Mean Std
RMSE (testset) 0.9040 0.8966 0.8894 0.8999 0.8988 0.8977 0.0048
MAE (testset) 0.6977 0.6912 0.6884 0.6919 0.6910 0.6920 0.0031
Fit time 3.95 3.97 3.97 3.95 4.04 3.98 0.03
Test time 0.18 0.10 0.10 0.10 0.10 0.12 0.03
{'test_rmse': array([0.90400821, 0.89663056, 0.88938934, 0.8998797 , 0.89880681]),
'test_mae': array([0.69772989, 0.69119595, 0.68844665, 0.69189097, 0.69095793]),
'fit_time': (3.94643497467041,
3.9701359272003174,
3.972831964492798,
3.9532768726348877,
4.037956237792969),
'test_time': (0.17850613594055176,
0.10392928123474121,
0.10480904579162598,
0.10410785675048828,
0.1036827564239502)}
In [8]:
In [9]:
In [10]:
The results are not identical to the results in the book since different folds are used in the training procedure.
In [11]:
Out[11]:
In [12]:
Out[12]: