O'Reilly logo

Building a Recommendation Engine with Scala by Saleem Ansari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding recommendation listings

Recall that in Chapter 6, Collaborative Filtering versus Content-Based Recommendation Engines, we trained a collaborative filtering based model using an ALS implementation of Apache Spark. Now that we already have it persisted we will re-use it to provide recommendations on a customer page.

Remember that when we trained that model, we had to create a rating object. This object had userId, productId, and a rating value. However, these values are specific to the algorithm, and are not related to our products, and customer IDs. So first, we need to recover those mappings. The following change to AmazonRatingALS does the job for us:

With this change, we will have both customer and product mappings, which we will use to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required