0
$\begingroup$

All the tutorials I can find about matrix factorization recommendation systems start with importing users, items, and user-item-ratings, but then only use the rating matrix to train the recommender (not features of the users or items themselves like "age").

Example

Tutorial: Matrix Factorization for Movie Recommendations in Python

URL: https://beckernick.github.io/matrix-factorization-recommender/

Users (userID, gender, ageGroup, occupationGroup, zipCode) enter image description here

Items (movieID, title, genres) enter image description here

Ratings (userID, movieID, rating, timestamp) enter image description here

Then we do some cleaning and build a matrix of users-to-items with ratings as the values. enter image description here

Then we proceed to to only use the matrix built from ratings (not other features of the user like age which I might guess has some predictive value).

# normalize data
import numpy as np
R = R_df.as_matrix()
user_ratings_mean = np.mean(R, axis=1)
R_demeaned = R - user_ratings_mean.reshape(-1,1)

# import numpy as np
R = R_df.as_matrix()
user_ratings_mean = np.mean(R, axis=1)
R_demeaned = R - user_ratings_mean.reshape(-1,1)

# SVD
import scipy
from scipy.sparse.linalg import svds
U, sigma, Vt = svds(R_demeaned, k=2)

# convert to diagonal matrix
sigma2 = np.diag(sigma)

# build predication matrix
all_user_predicted_ratings = np.dot(np.dot(U, sigma2), Vt) + user_ratings_mean.reshape(-1, 1)
preds_df = pd.DataFrame(all_user_predicted_ratings, columns = R_df.columns, dtype='float')

enter image description here

Theres more in the tutorial but at this point our predication matrix is already set.

  1. I wondered if this is just how matrix factorization recommenders work (aka. not use user/item features) or if online tutorials are just too simple?

  2. If I wanted to incorporate a user feature like age, would it be possible with matrix factorization?

$\endgroup$
1
$\begingroup$

If I wanted to incorporate a user feature like age, would it be possible with matrix factorization?

Yes, it's possible. It's commonly called a hybrid recommendation system.

$\endgroup$
0
$\begingroup$
  1. I wondered if this is just how matrix factorization recommenders work (aka. not use user/item features) or if online tutorials are just too simple?

In most of the cases, ALS or any other Matrix Factorization techniques are used for interaction data. Like: visits, clicks, skips, etc. We can have a hybrid matrix factorization, just in case you need to decide what to include in the User/Item matrix[Also termed as hybrid Recommendations]

  1. If I wanted to incorporate a user feature like age, would it be possible with matrix factorization?

Yes, you can, In can be complex to thought process to incorporate it into FMs. But it is surely possible.

Example

Counts:

  • user 1:30-50yrs old,
  • user2: 18-30yrs old,
  • user 3: <18.

Matrix can be made of the counts of the purchased products[i1,i2,i3] as below

enter image description here

This can be given as input to ALS to find out feature matrices for users and items.

Similary you can incorporate other features to create your recommendation engine

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.