org.apache.spark.mllib.recommendation
Class ALS

Object
  extended by org.apache.spark.mllib.recommendation.ALS
All Implemented Interfaces:
java.io.Serializable, Logging

public class ALS
extends Object
implements scala.Serializable, Logging

See Also:
Serialized Form

Constructor Summary
ALS()
           
 
Method Summary
 MatrixFactorizationModel run(JavaRDD<Rating> ratings)
           
 MatrixFactorizationModel run(RDD<Rating> ratings)
           
 ALS setAlpha(double alpha)
           
 ALS setBlocks(int numBlocks)
           
 ALS setCheckpointInterval(int checkpointInterval)
           
 ALS setFinalRDDStorageLevel(StorageLevel storageLevel)
           
 ALS setImplicitPrefs(boolean implicitPrefs)
           
 ALS setIntermediateRDDStorageLevel(StorageLevel storageLevel)
           
 ALS setIterations(int iterations)
           
 ALS setLambda(double lambda)
           
 ALS setNonnegative(boolean b)
           
 ALS setProductBlocks(int numProductBlocks)
           
 ALS setRank(int rank)
           
 ALS setSeed(long seed)
           
 ALS setUserBlocks(int numUserBlocks)
           
static MatrixFactorizationModel train(RDD<Rating> ratings, int rank, int iterations)
          Train a matrix factorization model given an RDD of ratings given by users to some products, in the form of (userID, productID, rating) pairs.
static MatrixFactorizationModel train(RDD<Rating> ratings, int rank, int iterations, double lambda)
          Train a matrix factorization model given an RDD of ratings given by users to some products, in the form of (userID, productID, rating) pairs.
static MatrixFactorizationModel train(RDD<Rating> ratings, int rank, int iterations, double lambda, int blocks)
           
static MatrixFactorizationModel train(RDD<Rating> ratings, int rank, int iterations, double lambda, int blocks, long seed)
           
static MatrixFactorizationModel trainImplicit(RDD<Rating> ratings, int rank, int iterations)
          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.
static MatrixFactorizationModel trainImplicit(RDD<Rating> ratings, int rank, int iterations, double lambda, double alpha)
          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.
static MatrixFactorizationModel trainImplicit(RDD<Rating> ratings, int rank, int iterations, double lambda, int blocks, double alpha)
          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.
static MatrixFactorizationModel trainImplicit(RDD<Rating> ratings, int rank, int iterations, double lambda, int blocks, double alpha, long seed)
          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.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.spark.Logging
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
 

Constructor Detail

ALS

public ALS()
Method Detail

train

public static MatrixFactorizationModel train(RDD<Rating> ratings,
                                             int rank,
                                             int iterations,
                                             double lambda,
                                             int blocks,
                                             long seed)

train

public static MatrixFactorizationModel train(RDD<Rating> ratings,
                                             int rank,
                                             int iterations,
                                             double lambda,
                                             int blocks)

train

public static MatrixFactorizationModel train(RDD<Rating> ratings,
                                             int rank,
                                             int iterations,
                                             double lambda)
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. The level of parallelism is determined automatically based on the number of partitions in ratings.

Parameters:
ratings - RDD of (userID, productID, rating) pairs
rank - number of features to use
iterations - number of iterations of ALS (recommended: 10-20)
lambda - regularization factor (recommended: 0.01)
Returns:
(undocumented)

train

public static MatrixFactorizationModel train(RDD<Rating> ratings,
                                             int rank,
                                             int iterations)
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. The level of parallelism is determined automatically based on the number of partitions in ratings.

Parameters:
ratings - RDD of (userID, productID, rating) pairs
rank - number of features to use
iterations - number of iterations of ALS (recommended: 10-20)
Returns:
(undocumented)

trainImplicit

public static MatrixFactorizationModel trainImplicit(RDD<Rating> ratings,
                                                     int rank,
                                                     int iterations,
                                                     double lambda,
                                                     int blocks,
                                                     double alpha,
                                                     long seed)
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:
ratings - RDD of (userID, productID, rating) pairs
rank - number of features to use
iterations - number of iterations of ALS (recommended: 10-20)
lambda - regularization factor (recommended: 0.01)
blocks - level of parallelism to split computation into
alpha - confidence parameter
seed - random seed
Returns:
(undocumented)

trainImplicit

public static MatrixFactorizationModel trainImplicit(RDD<Rating> ratings,
                                                     int rank,
                                                     int iterations,
                                                     double lambda,
                                                     int blocks,
                                                     double alpha)
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:
ratings - RDD of (userID, productID, rating) pairs
rank - number of features to use
iterations - number of iterations of ALS (recommended: 10-20)
lambda - regularization factor (recommended: 0.01)
blocks - level of parallelism to split computation into
alpha - confidence parameter
Returns:
(undocumented)

trainImplicit

public static MatrixFactorizationModel trainImplicit(RDD<Rating> ratings,
                                                     int rank,
                                                     int iterations,
                                                     double lambda,
                                                     double alpha)
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:
ratings - RDD of (userID, productID, rating) pairs
rank - number of features to use
iterations - number of iterations of ALS (recommended: 10-20)
lambda - regularization factor (recommended: 0.01)
alpha - confidence parameter
Returns:
(undocumented)

trainImplicit

public static MatrixFactorizationModel trainImplicit(RDD<Rating> ratings,
                                                     int rank,
                                                     int iterations)
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:
ratings - RDD of (userID, productID, rating) pairs
rank - number of features to use
iterations - number of iterations of ALS (recommended: 10-20)
Returns:
(undocumented)

setBlocks

public ALS setBlocks(int numBlocks)

setUserBlocks

public ALS setUserBlocks(int numUserBlocks)

setProductBlocks

public ALS setProductBlocks(int numProductBlocks)

setRank

public ALS setRank(int rank)

setIterations

public ALS setIterations(int iterations)

setLambda

public ALS setLambda(double lambda)

setImplicitPrefs

public ALS setImplicitPrefs(boolean implicitPrefs)

setAlpha

public ALS setAlpha(double alpha)

setSeed

public ALS setSeed(long seed)

setNonnegative

public ALS setNonnegative(boolean b)

setIntermediateRDDStorageLevel

public ALS setIntermediateRDDStorageLevel(StorageLevel storageLevel)

setFinalRDDStorageLevel

public ALS setFinalRDDStorageLevel(StorageLevel storageLevel)

setCheckpointInterval

public ALS setCheckpointInterval(int checkpointInterval)

run

public MatrixFactorizationModel run(RDD<Rating> ratings)

run

public MatrixFactorizationModel run(JavaRDD<Rating> ratings)