new MatrixFactorizationModel(rank, userFeatures, productFeatures)
Parameters:
Name | Type | Description |
---|---|---|
rank |
number | |
userFeatures |
module:eclairjs.RDD | |
productFeatures |
module:eclairjs.RDD |
Methods
(static) load(sc, path) → {module:eclairjs/mllib/recommendation.MatrixFactorizationModel}
Load a model from the given path.
The model should have been saved by save.
Parameters:
Name | Type | Description |
---|---|---|
sc |
module:eclairjs.SparkContext | Spark context used for loading model files. |
path |
string | Path specifying the directory to which the model was saved. |
Returns:
Model instance
predict(user, productopt) → {module:eclairjs.RDD|number}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
user |
integer | module:eclairjs.RDD | ||
product |
integer |
<optional> |
Required if argument one is integer |
Returns:
- Type
- module:eclairjs.RDD | number
productFeatures() → {module:eclairjs.RDD}
Returns:
- Type
- module:eclairjs.RDD
recommendProducts(user, num) → {Array.<module:eclairjs/mllib/recommendation.Rating>}
Recommends products to a user.
Parameters:
Name | Type | Description |
---|---|---|
user |
number | the user to recommend products to |
num |
number | how many products to return. The number returned may be less than this. "score" in the rating field. Each represents one recommended product, and they are sorted by score, decreasing. The first returned is the one predicted to be most strongly recommended to the user. The score is an opaque value that indicates how strongly recommended the product is. |
Returns:
[[module:eclairjs/mllib/recommendation.Rating]] objects, each of which contains the given user ID, a product ID, and a
- Type
- Array.<module:eclairjs/mllib/recommendation.Rating>
recommendProductsForUsers(num) → {module:eclairjs.RDD}
Recommends topK products for all users.
Parameters:
Name | Type | Description |
---|---|---|
num |
number | how many products to return for every user. rating objects which contains the same userId, recommended productID and a "score" in the rating field. Semantics of score is same as recommendProducts API |
Returns:
[(Int, Array[Rating])] objects, where every tuple contains a userID and an array of
- Type
- module:eclairjs.RDD
recommendUsers(product, num) → {Array.<module:eclairjs/mllib/recommendation.Rating>}
Recommends users to a product. That is, this returns users who are most likely to be
interested in a product.
Parameters:
Name | Type | Description |
---|---|---|
product |
number | the product to recommend users to |
num |
number | how many users to return. The number returned may be less than this. "score" in the rating field. Each represents one recommended user, and they are sorted by score, decreasing. The first returned is the one predicted to be most strongly recommended to the product. The score is an opaque value that indicates how strongly recommended the user is. |
Returns:
[[module:eclairjs/mllib/recommendation.Rating]] objects, each of which contains a user ID, the given product ID, and a
- Type
- Array.<module:eclairjs/mllib/recommendation.Rating>
recommendUsersForProducts(num) → {module:eclairjs.RDD}
Recommends topK users for all products.
Parameters:
Name | Type | Description |
---|---|---|
num |
number | how many users to return for every product. of rating objects which contains the recommended userId, same productID and a "score" in the rating field. Semantics of score is same as recommendUsers API |
Returns:
[(Int, Array[Rating])] objects, where every tuple contains a productID and an array
- Type
- module:eclairjs.RDD
save(sc, path, overwriteopt)
Save this model to the given path.
This saves:
- human-readable (JSON) model metadata to path/metadata/
- Parquet formatted data to path/data/
The model may be loaded using load.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sc |
module:eclairjs.SparkContext | Spark context used to save model data. | |
path |
string | Path specifying the directory in which to save this model. If the directory already exists, this method throws an exception. | |
overwrite |
boolean |
<optional> |
if true overwrites the model, defaults to false; |
userFeatures() → {module:eclairjs.RDD}
Returns:
- Type
- module:eclairjs.RDD