How to make recommendation based on elements in spark mllib?

Mahout has support for recommending elements using the API method:

ItemBasedRecommender.mostSimilarItems(int productid, int maxResults, Rescorer rescorer) 

But in Spark Mllib, it seems that the APIs in ALS can retrieve recommended products, but the userid should be provided through:

 MatrixFactorizationModel.recommendProducts(int user, int num) 

Is there a way to get recommended products based on a similar product without having to provide user identification information similar to how mahout implements item-based recommendation.

+7
recommendation-engine mahout apache-spark apache-spark-mllib
source share
2 answers

versions of Spark 1.2x do not contain a β€œrecommendation based on details,” such as those found in Mahout.

However, MLlib currently supports collaborative filtering based on models, where users and products are described by a small set of hidden factors {Understand the use case for implicit (views, clicks) and explicit feedback (ratings) when constructing the user interface, matrix of elements.}

MLlib uses the alternating least squares (ALS) algorithm [can be considered similar to the SVD algorithm] to study these hidden factors.

If you need to create a recommendation based on the details, I would recommend the following:

  • Represent all elements using a vector function
  • Construct a similarity matrix for the item element by computing a similarity metric (e.g., cosine) with each pair of elements
  • Use this similarity matrix to find similar elements for users.

Since similarity matrices do not scale well (imagine how your similarity matrix will grow if you had 100 items versus 10,000 items), this reading on DIMSUM may be useful if you plan to implement it on a large number of items:

https://databricks.com/blog/2014/10/20/efficient-similarity-algorithm-now-in-spark-twitter.html

+11
source share

Please check out my implementation of the item item recommendation model using Apache Spark here. You can implement this using the resulting productFeatures matrix when you run the MLib ALS algorithm for these custom products. The ALS algorithm significantly factorizes two matrices: one is userFeatures, and the other is productFeatures. You can run the cosine affinity on the productFeatures rank matrix to find the affinity of the product elements.

+3
source share

All Articles