RECOMMEND Procedure

Example 1: Recommendations from Explicit Ratings

Details

Problem Description

This example draws on data that is derived from online movie viewing companies. A company wants to offer its customers recommendations of movies that they might like. These recommendations are based on ratings that are provided by users. The following table contains an example of a user-item-ratings matrix that online movie viewing companies might use.
Sample Movie Ratings from Customers
Customers
Movie 1
Movie 2
Movie 3
Movie 4
Movie 5
User 1
4
4
4
User 2
1
1
User 3
5
4
5
4
In the sample data, customers rate the movies that they have seen using a 1–5 scale, where 1 is the lowest rating and 5 is the highest rating. This table represents a user-item-ratings matrix. Blank cells correspond to movies that a customer has not rated.
In practice, the matrix would be even more sparse than the sample data, as the typical customer rates only a very small fraction of all available movies. The goal of the recommender system is to predict ratings for all of the blank cells. Would User 1 like Movie 4? From the sample above, there is very little data available. However, with much more data, we might observe that User 1 and User 3 have similar taste in movies. Therefore, we could conclude that User 1 would also give Item 4 a high rating, based on the information that we already have from User 3. In a real-world situation, it is not necessary to predict every blank entry in a utility matrix. The system is required to supply only a few suggestions that a customer would rate highly.

Example Data

This example uses the MovieLens data set (1M) that was developed by the GroupLens project at the University of Minnesota. The data that is displayed was downloaded in February 2014 from the GroupLens website.
Note: Per University of Minnesota guidelines, you cannot use this data for any commercial or revenue-bearing purpose without first obtaining permission from a faculty member of the GroupLens Research Project.
Before invoking the RECOMMEND procedure, we can print a part of the tables that are included in the recommender system by invoking the IMSTAT procedure.
proc imstat;
   table MYlasr.movierating; 
   fetch/format;
   run;

   table MYlasr.movieprofile;
   fetch/format;
   run;

   table MYlasr.userprofile;
   fetch/format;
   run;
quit;
The first FETCH statement prints a portion of the MovieRating table. The table contains rating information made by users (customers) about items (movies).
Sample Data from the MovieRatings Table
Sample data from the MovieRatings table
The second and third FETCH statements print a portion of the MovieProfile and UserProfile tables. These tables contain information about each movie and user (customer), respectively.
Sample Profile Data
Sample data from the MovieProfile table
Sample data from UserProfile table

Program

proc recommend port=&portNumber recom = rs.movielens;
   add rs.movielens /item = itemid user = userid rating = rating; 1
   
   addtable MYlasr.movierating  / recom = rs.movielens type = rating 
                                  vars=(itemid userid rating); 2
   addtable MYlasr.movieprofile  / recom = rs.movielens type = item;
   addtable MYlasr.userprofile   / recom = rs.movielens type = user;
   run; 

   method knn / label = "knn" k = 20 positive similarity = pc seed = 1234; 3
   run;
   
   method slope1 /label = "slope1"; 
   run;
    
   method svd / factors = 20 label = "svd" fconv = 1e-3 gconv = 1e-3 
                maxiter = 100 seed = 1234 MAXFEVAL = 5000 function=L2 
                lamda = 0.2 technique = lbfgs; 
   run;

   method ensemble / methods =("svd","knn") label = "ensemble" details 
                     MAXFEVAL=5000 maxiter=100 seed=1234 hold=2
                     withhold=0.1; 
   run;

   predict / method = knn  label="knn" Num = 5 
             users = ("1","33","478","2035"); 4
   run;

   info; 5
   run;

   remove rs.movielens; 6
run;

Program Description

  1. The ADD statement adds a recommender system, MovieLens, to the SAS LASR Analytic Server.
  2. Three ADDTABLE statements add the MovieRating, MovieProfile, and UserProfile tables to the recommender system.
  3. Each METHOD statement adds a method for computing recommendations to the recommender system. The methods KNN, SLOPE1, SVD, and ENSEMBLE were added with options specified for each method. For more information, see METHOD Statement.
  4. The PREDICT statement generates five predictions for each specified user (1, 33, 478, and 2035).
  5. The INFO statement requests information about all recommender systems on the SAS LASR Analytic Server. You can also specify a specific recommender system in the INFO statement to filter the results.
  6. The REMOVE statement removes a recommender system from the server or removes a method.

METHOD Statement Output

Output from the METHOD Statement Using the ENSEMBLE Option
Output from METHOD statement with ENSEMBLE method
Output from the METHOD Statement Using the Details Option
Output from the METHOD statement with the DETAILS option

PREDICT Statement Output

Output from the PREDICT Statement
Sample output from the PREDICT statement

INFO Statement Output

Output from the INFO Statement
Output from the INFO statement