Recommender Systems¶
Collaborative Filtering¶
-
touvlo.rec_sys.cf.
cost_function
(X, Y, R, theta, _lambda)[source]¶ Computes the cost function J for Collaborative Filtering.
Parameters: - X (numpy.array) – Matrix of product features.
- Y (numpy.array) – Scores’ matrix.
- R (numpy.array) – Matrix of 0s and 1s (whether there’s a rating).
- theta (numpy.array) – Matrix of user features.
- _lambda (float) – The regularization hyperparameter.
Returns: Computed cost.
Return type:
-
touvlo.rec_sys.cf.
grad
(params, Y, R, num_users, num_products, num_features, _lambda)[source]¶ Calculates gradient of Collaborative Filtering’s parameters
Parameters: - params (numpy.array) – flattened product and user features..
- Y (numpy.array) – Scores’ matrix.
- R (numpy.array) – Matrix of 0s and 1s (whether there’s a rating).
- num_users (int) – Number of users in this instance.
- num_products (int) – Number of products in this instance.
- num_features (int) – Number of features in this instance.
- _lambda (float) – The regularization hyperparameter.
Returns: Flattened gradient of product and user parameters.
Return type: numpy.array