concept recommendation in category machine learning

appears as: recommendations, recommendation, recommendation, recommendations, A recommendation
Algorithms of the Intelligent Web, Second Edition

This is an excerpt from Manning's book Algorithms of the Intelligent Web, Second Edition.

Nevertheless, the realm of intelligent web applications extends well beyond search engines. Amazon was one of the first online stores that offered recommendations to its users based on their shopping patterns. You may be familiar with that feature. Let’s say that you purchase a book on JavaServer Faces and a book on Python. As soon as you add your items to the shopping cart, Amazon will recommend additional items that are somehow related to the ones you’ve just selected; it might recommend books that involve AJAX or Ruby on Rails. In addition, during your next visit to the Amazon website, the same or other related items may be recommended. Another intelligent web application is Netflix, which is the world’s largest online movie streaming service, offering more than 53 million subscribers access to an ever-changing library of full-length movies and television episodes that are available to stream instantly.

In today’s world, we’re overwhelmed with choices, with a plethora of options available for nearly every aspect of our lives. We need to make decisions on a daily basis, from automobiles to home theatre systems, from finding Mr. or Ms. “Perfect” to selecting attorneys or accountants, from books and newspapers to wikis and blogs. In addition, we’re constantly being bombarded by information—and occasionally misinformation! Under these conditions, the ability to recommend a choice is valuable, and even more so if that choice is aligned with the person receiving the recommendation.

An ancient Greek proverb (with similar variants in nearly every culture of the world) states, “Show me your friends, and I’ll tell you who you are.” Collaborative filtering based on neighborhoods of similar users is more or less an algorithmic incarnation of that proverb. In order to evaluate the rating of a particular user for a given item, you look for the ratings of similar users (neighbors or friends, if you prefer) on the same item. Then, you multiply the rating of each friend by a weight and add them—it’s that simple! The following listing shows the code to provide a recommendation based on user similarity. We use the same data as we did to demonstrate different measures of similarity—the data given in table 3.1.

Listing 3.3. User-based CF recommendation
data = Data() format = {'col':0, 'row':1, 'value':2, 'ids': 'int'} data.load(dat_file, sep='::', format=format) similarity_matrix = SimilarityMatrix() recommend(0,10) #1 recommend(1,10) #2 recommend(2,10) #3 #1 - Provides the top 10 recommendations for user 0 (Frank) #2 - Provides the top 10 recommendations for user 1 (Constantine) #3 - Provides the top 10 recommendations for user 2 (Catherine)

Listing 3.3 provides the high-level code to perform user-based CF. We read in the data using the load method in recsys.datamodel.data. The recommend method is then used to provide recommendations of movies that the user should consider. More accurately, the method provides a prediction of the ratings that the user would give for particular movies. These are ordered, and the top 10 are returned. The recommend method predicts ratings for only those items that haven’t already been rated by the user. With the dataset used, there are fewer than 10 movies unseen for each user; hence, this limit is never hit. You might also come across the “None” rating. This occurs only where the user hasn’t rated the movie and no other users in the dataset have rated it, either. Thus, this represents not a zero rating but a lack of rating.

To provide an example, if you run the code, you’ll see that Constantine is recommended Jumanji, Waiting to Exhale, and Sabrina, mainly because Frank has rated these films. Constantine is similar to Frank (as you saw previously), and Frank has rated them highly. It seems that our recommendation engine is working well. You’ll note that the recommendations for each user are only for films that they haven’t seen or rated themselves, and that recommendations appear to be made based on the tastes of similar users.

Listing 3.8. SVD for recommendation
svd = SVD() recsys.algorithm.VERBOSE = True #1 dat_file = './ml-1m/ratings.dat' #2 item_file = './ml-1m/movies.dat' #3 data = Data() data.load(dat_file, sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int}) items_full = read_item_data(item_file) user_full = read_user_data_from_ratings(dat_file) svd.set_data(data) #1 - Sends back progress to the screen #2 - User ratings #3 - Movie info
Mahout in Action

This is an excerpt from Manning's book Mahout in Action.

  • Amazon.com is perhaps the most famous e-commerce site to deploy recommendations. Based on purchases and site activity, Amazon recommends books and other items likely to be of interest. See figure 1.2.
  • Although 130 million preferences is still a manageable size for demonstration purposes, it’s of such a scale that a single machine would have trouble processing recommendations from it in the way we’ve presented so far. It calls for a new species of recommender algorithm, using a distributed computing approach from Mahout based on the MapReduce paradigm and Apache Hadoop.

    6.3.6. Translating to MapReduce: making recommendations

    At last, the pieces of the recommendation vector must be assembled for each user so that the algorithm can make recommendations. The following listing shows this in action.

    Listing 6.9. Producing recommendations from vectors

    6.2.3. Producing the recommendations

    To compute recommendations for user 3, merely multiply this vector, as a column vector, with the co-occurrence matrix, as shown in table 6.2.

    Table 6.2. Multiplying the co-occurrence matrix with user 3’s preference vector (U3) to produce a vector that leads to recommendations, R
                           
     

    101

    102

    103

    104

    105

    106

    107

     

    U3

     

    R

    101 5 3 4 4 2 2 1   2.0   40.0
    102 3 3 3 2 1 1 0   0.0   18.5
    103 4 3 4 3 1 2 0 X 0.0 = 24.5
    104 4 2 3 4 2 2 1   4.0   40.0
    105 2 1 1 2 2 1 1   4.5   26.0
    106 2 1 2 2 1 2 0   0.0   16.5
    107 1 0 0 1 1 0 1   5.0   15.5

    Take a moment to review how matrix multiplication works, if needed (http://en.wikipedia.org/wiki/Matrix_multiplication). The product of the co-occurrence matrix and a user vector is itself a vector whose dimension is equal to the number of items. The values in this resulting vector, R, lead us directly to recommendations: the highest values in R correspond to the best recommendations.

    Table 6.2 shows this multiplication for user 3 in the small example data set, and the resulting vector R. It’s possible to ignore the values in rows of R corresponding to items 101, 104, 105, and 107 (shown in italic) because these aren’t eligible for recommendation: user 3 already expresses a preference for these items. Of the remaining items, the entry for item 103 is highest, with a value of 24.5, and would therefore be the top recommendation, followed by 102 and 106.

    Collective Intelligence in Action

    This is an excerpt from Manning's book Collective Intelligence in Action.

    In October 2006, Google bought YouTube for $1.65 billion. In its 20 months of existence, YouTube had grown to be one of the busiest sites on the Internet, dishing out 100 million video[2] views a day. It ramped from zero to more than 20 million unique user visits a day, with mainly viral marketing—spread from person to person, similar to the way the pandemic flu spreads. In YouTube’s case, each time a user uploaded a new video, she was easily able to invite others to view this video. As those others viewed this video, other related videos popped up as recommendations, keeping the user further engaged. Ultimately, many of these viewers also became submitters and uploaded their own videos as well. As the number of videos increased, the site became more and more attractive for new users to visit.

    Reviews and Recommendations

    A recommendation made by a friend or a person of influence can have a big impact on other users within the same group. Moreover, a review or comments about a user’s experience with a particular provider or service is contextually relevant for other users inquiring about that topic, especially if it’s within the context of similar use.

    Figure 12.7. Screenshot of recommendations to a user at Amazon.com