Class: ALS

eclairjs/mllib/recommendation.ALS

new ALS() → (nullable) {?}

Constructs an ALS instance with default parameters: {numBlocks: -1, rank: 10, iterations: 10, lambda: 0.01, implicitPrefs: false, alpha: 1.0}.
Source:
Returns:
Type
?

Methods

(static) train(ratings, rank, iterations, lambdaopt, blocksopt, seedopt) → {module:eclairjs/mllib/recommendation.MatrixFactorizationModel}

Train a matrix factorization model given an RDD of ratings given by users to some products, in the form of (userID, productID, rating) pairs. We approximate the ratings matrix as the product of two lower-rank matrices of a given rank (number of features). To solve for these features, we run a given number of iterations of ALS. This is done using a level of parallelism given by `blocks`.
Parameters:
Name Type Attributes Description
ratings module:eclairjs/rdd.RDD RDD of (userID, productID, rating) pairs
rank number number of features to use
iterations number number of iterations of ALS (recommended: 10-20)
lambda number <optional>
regularization factor (recommended: 0.01)
blocks number <optional>
level of parallelism to split computation into
seed number <optional>
random seed
Source:
Returns:
Type
module:eclairjs/mllib/recommendation.MatrixFactorizationModel

(static) trainImplicit0(ratings, rank, iterations, lambda, blocks, alpha, seed) → {module:eclairjs/mllib/recommendation.MatrixFactorizationModel}

Train a matrix factorization model given an RDD of 'implicit preferences' given by users to some products, in the form of (userID, productID, preference) pairs. We approximate the ratings matrix as the product of two lower-rank matrices of a given rank (number of features). To solve for these features, we run a given number of iterations of ALS. This is done using a level of parallelism given by `blocks`.
Parameters:
Name Type Description
ratings module:eclairjs/rdd.RDD RDD of (userID, productID, rating) pairs
rank number number of features to use
iterations number number of iterations of ALS (recommended: 10-20)
lambda number regularization factor (recommended: 0.01)
blocks number level of parallelism to split computation into
alpha number confidence parameter
seed number random seed
Source:
Returns:
Type
module:eclairjs/mllib/recommendation.MatrixFactorizationModel

(static) trainImplicit1(ratings, rank, iterations, lambda, blocks, alpha) → {module:eclairjs/mllib/recommendation.MatrixFactorizationModel}

Train a matrix factorization model given an RDD of 'implicit preferences' given by users to some products, in the form of (userID, productID, preference) pairs. We approximate the ratings matrix as the product of two lower-rank matrices of a given rank (number of features). To solve for these features, we run a given number of iterations of ALS. This is done using a level of parallelism given by `blocks`.
Parameters:
Name Type Description
ratings module:eclairjs/rdd.RDD RDD of (userID, productID, rating) pairs
rank number number of features to use
iterations number number of iterations of ALS (recommended: 10-20)
lambda number regularization factor (recommended: 0.01)
blocks number level of parallelism to split computation into
alpha number confidence parameter
Source:
Returns:
Type
module:eclairjs/mllib/recommendation.MatrixFactorizationModel

(static) trainImplicit2(ratings, rank, iterations, lambda, alpha) → {module:eclairjs/mllib/recommendation.MatrixFactorizationModel}

Train a matrix factorization model given an RDD of 'implicit preferences' given by users to some products, in the form of (userID, productID, preference) pairs. We approximate the ratings matrix as the product of two lower-rank matrices of a given rank (number of features). To solve for these features, we run a given number of iterations of ALS. The level of parallelism is determined automatically based on the number of partitions in `ratings`.
Parameters:
Name Type Description
ratings module:eclairjs/rdd.RDD RDD of (userID, productID, rating) pairs
rank number number of features to use
iterations number number of iterations of ALS (recommended: 10-20)
lambda number regularization factor (recommended: 0.01)
alpha number confidence parameter
Source:
Returns:
Type
module:eclairjs/mllib/recommendation.MatrixFactorizationModel

(static) trainImplicit3(ratings, rank, iterations) → {module:eclairjs/mllib/recommendation.MatrixFactorizationModel}

Train a matrix factorization model given an RDD of 'implicit preferences' ratings given by users to some products, in the form of (userID, productID, rating) pairs. We approximate the ratings matrix as the product of two lower-rank matrices of a given rank (number of features). To solve for these features, we run a given number of iterations of ALS. The level of parallelism is determined automatically based on the number of partitions in `ratings`. Model parameters `alpha` and `lambda` are set to reasonable default values
Parameters:
Name Type Description
ratings module:eclairjs/rdd.RDD RDD of (userID, productID, rating) pairs
rank number number of features to use
iterations number number of iterations of ALS (recommended: 10-20)
Source:
Returns:
Type
module:eclairjs/mllib/recommendation.MatrixFactorizationModel

runwithJavaRDD(ratings) → {module:eclairjs/mllib/recommendation.MatrixFactorizationModel}

Java-friendly version of run.
Parameters:
Name Type Description
ratings JavaRDD
Source:
Returns:
Type
module:eclairjs/mllib/recommendation.MatrixFactorizationModel

runwithRDD(ratings) → {module:eclairjs/mllib/recommendation.MatrixFactorizationModel}

Run ALS with the configured parameters on an input RDD of (user, product, rating) triples. Returns a MatrixFactorizationModel with feature vectors for each user and product.
Parameters:
Name Type Description
ratings module:eclairjs/rdd.RDD
Source:
Returns:
Type
module:eclairjs/mllib/recommendation.MatrixFactorizationModel

setAlpha(alpha)

Sets the constant used in computing confidence in implicit ALS. Default: 1.0.
Parameters:
Name Type Description
alpha number
Source:
Returns:

setBlocks(numBlocks)

Set the number of blocks for both user blocks and product blocks to parallelize the computation into; pass -1 for an auto-configured number of blocks. Default: -1.
Parameters:
Name Type Description
numBlocks number
Source:
Returns:

setImplicitPrefs(implicitPrefs)

Parameters:
Name Type Description
implicitPrefs boolean
Source:
Returns:

setIterations(iterations)

Parameters:
Name Type Description
iterations number
Source:
Returns:

setLambda(lambda)

Parameters:
Name Type Description
lambda number
Source:
Returns:

setNonnegative(b)

Set whether the least-squares problems solved at each iteration should have nonnegativity constraints.
Parameters:
Name Type Description
b boolean
Source:
Returns:

setProductBlocks(numProductBlocks)

Set the number of product blocks to parallelize the computation.
Parameters:
Name Type Description
numProductBlocks number
Source:
Returns:

setRank(rank)

Parameters:
Name Type Description
rank number
Source:
Returns:

setSeed(seed)

Parameters:
Name Type Description
seed number
Source:
Returns:

setUserBlocks(numUserBlocks)

Set the number of user blocks to parallelize the computation.
Parameters:
Name Type Description
numUserBlocks number
Source:
Returns: