diff options
author | Vladimir Vladimirov <vladimir.vladimirov@magnetic.com> | 2015-10-09 14:16:13 -0700 |
---|---|---|
committer | Davies Liu <davies.liu@gmail.com> | 2015-10-09 14:16:13 -0700 |
commit | c1b4ce43264fa8b9945df3c599a51d4d2a675705 (patch) | |
tree | 192333393be8d38f558327659a03904e5d3a5c68 /mllib | |
parent | 63c340a710b24869410d56602b712fbfe443e6f0 (diff) | |
download | spark-c1b4ce43264fa8b9945df3c599a51d4d2a675705.tar.gz spark-c1b4ce43264fa8b9945df3c599a51d4d2a675705.tar.bz2 spark-c1b4ce43264fa8b9945df3c599a51d4d2a675705.zip |
[SPARK-10535] Sync up API for matrix factorization model between Scala and PySpark
Support for recommendUsersForProducts and recommendProductsForUsers in matrix factorization model for PySpark
Author: Vladimir Vladimirov <vladimir.vladimirov@magnetic.com>
Closes #8700 from smartkiwi/SPARK-10535_.
Diffstat (limited to 'mllib')
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/mllib/api/python/MatrixFactorizationModelWrapper.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/mllib/api/python/MatrixFactorizationModelWrapper.scala b/mllib/src/main/scala/org/apache/spark/mllib/api/python/MatrixFactorizationModelWrapper.scala index 534edac56b..eeb7cba882 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/api/python/MatrixFactorizationModelWrapper.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/api/python/MatrixFactorizationModelWrapper.scala @@ -42,4 +42,12 @@ private[python] class MatrixFactorizationModelWrapper(model: MatrixFactorization case (product, feature) => (product, Vectors.dense(feature)) }.asInstanceOf[RDD[(Any, Any)]]) } + + def wrappedRecommendProductsForUsers(num: Int): RDD[Array[Any]] = { + SerDe.fromTuple2RDD(recommendProductsForUsers(num).asInstanceOf[RDD[(Any, Any)]]) + } + + def wrappedRecommendUsersForProducts(num: Int): RDD[Array[Any]] = { + SerDe.fromTuple2RDD(recommendUsersForProducts(num).asInstanceOf[RDD[(Any, Any)]]) + } } |