(Algorithm)

collaborative filtering is an approach to recommender system recommend items to you based on ratings of users similar to you. It is largely an unsupervised learning algorithm.

Neighborhood-based

neighborhood-based collaborative filtering

(Algorithm) (Code Lab)

neighborhood-based collaborative filtering is a specific collaborative filtering algorithm to recommender system. It predict sthe degree of preference for an item of a user based on other similar users’ ratings. Similarity is determined by their preferences for known items.

For example, both users and rate movies 5 stars. Given user also like movie , user might also like it.

Process

  1. Mean normalization
  2. Cost function
  3. gradient descent

Cost function

(Algorithm) The algorithm can learn features based on known user ratings (), then proceed to learn usual parameters .

numberingtotal number
item
user
feature

This cost function can be minimized using gradient descent

Mean normalization

(Mean normalization)

w^{(j)}\cdot x^{(i)} +b^{(j)}+\textcolor{red}{\mu_{i}}

You can't use 'macro parameter character #' in math mode # Usage Recommend new, similar items to users ## Limitations In these situations, [[collaborative filtering]] might not be very accurate. - Cold start problem. How to - rank *NEW ITEMS* that few users have rated? - show something reasonable to *NEW USERS* who have rated few items? - Lack side information about items or users (i.e. web browser) Note that these limitations could be alleviated through [[content-based filtering]] # Implementation ([Tensorflow](https://www.coursera.org/learn/unsupervised-learning-recommenders-reinforcement-learning/lecture/wmHWA/tensorflow-implementation-of-collaborative-filtering)) ```python import tensorflow as tf def cofi_cost_func_v(X, W, b, Y, R, lambda_): """ Returns the cost for the content-based filtering Vectorized for speed. Uses tensorflow operations to be compatible with custom training loop. Args: X (ndarray (num_movies,num_features)): matrix of item features W (ndarray (num_users,num_features)) : matrix of user parameters b (ndarray (1, num_users) : vector of user parameters Y (ndarray (num_movies,num_users) : matrix of user ratings of movies R (ndarray (num_movies,num_users) : matrix, where R(i, j) = 1 if the i-th movies was rated by the j-th user lambda_ (float): regularization parameter Returns: J (float) : Cost """ j = (tf.linalg.matmul(X, tf.transpose(W)) + b - Y)*R J = 0.5 * tf.reduce_sum(j**2) + (lambda_/2) * (tf.reduce_sum(X**2) + tf.reduce_sum(W**2)) return J ```Link to original

Matrix Factorization