org.apache.spark.mllib.recommendation

ALS

class ALS extends Serializable with Logging

Alternating Least Squares matrix factorization.

ALS attempts to estimate the ratings matrix R as the product of two lower-rank matrices, X and Y, i.e. Xt * Y = R. Typically these approximations are called 'factor' matrices. The general approach is iterative. During each iteration, one of the factor matrices is held constant, while the other is solved for using least squares. The newly-solved factor matrix is then held constant while solving for the other factor matrix.

This is a blocked implementation of the ALS factorization algorithm that groups the two sets of factors (referred to as "users" and "products") into blocks and reduces communication by only sending one copy of each user vector to each product block on each iteration, and only for the product blocks that need that user's feature vector. This is achieved by precomputing some information about the ratings matrix to determine the "out-links" of each user (which blocks of products it will contribute to) and "in-link" information for each product (which of the feature vectors it receives from each user block it will depend on). This allows us to send only an array of feature vectors between each user block and product block, and have the product block find the users' ratings and update the products based on these messages.

For implicit preference data, the algorithm used is based on "Collaborative Filtering for Implicit Feedback Datasets", available at http://research.yahoo.com/pub/2433, adapted for the blocked approach used here.

Essentially instead of finding the low-rank approximations to the rating matrix R, this finds the approximations for a preference matrix P where the elements of P are 1 if r > 0 and 0 if r = 0. The ratings then act as 'confidence' values related to strength of indicated user preferences rather than explicit ratings given to items.

Linear Supertypes
Logging, Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ALS
  2. Logging
  3. Serializable
  4. Serializable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ALS()

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. var alpha: Double

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def computeYtY(factors: RDD[(Int, Array[Array[Double]])]): Option[DoubleMatrix]

    Computes the (rank x rank) matrix YtY, where Y is the (nui x rank) matrix of factors for each user (or product), in a distributed fashion.

    Computes the (rank x rank) matrix YtY, where Y is the (nui x rank) matrix of factors for each user (or product), in a distributed fashion. Here reduceByKeyLocally is used as the driver program requires YtY to broadcast it to the slaves

    factors

    the (block-distributed) user or product factor vectors

    returns

    Option[YtY] - whose value is only used in the implicit preference model

  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  15. var implicitPrefs: Boolean

  16. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  17. def isTraceEnabled(): Boolean

    Attributes
    protected
    Definition Classes
    Logging
  18. var iterations: Int

  19. var lambda: Double

  20. def log: Logger

    Attributes
    protected
    Definition Classes
    Logging
  21. def logDebug(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  22. def logDebug(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  23. def logError(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  24. def logError(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  25. def logInfo(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  26. def logInfo(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  27. def logTrace(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  28. def logTrace(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  29. def logWarning(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  30. def logWarning(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  31. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  32. final def notify(): Unit

    Definition Classes
    AnyRef
  33. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  34. var numBlocks: Int

  35. var rank: Int

  36. def run(ratings: RDD[Rating]): MatrixFactorizationModel

    Run ALS with the configured parameters on an input RDD of (user, product, rating) triples.

    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.

  37. def setAlpha(alpha: Double): ALS

  38. def setBlocks(numBlocks: Int): ALS

    Set the number of blocks to parallelize the computation into; pass -1 for an auto-configured number of blocks.

    Set the number of blocks to parallelize the computation into; pass -1 for an auto-configured number of blocks. Default: -1.

  39. def setImplicitPrefs(implicitPrefs: Boolean): ALS

  40. def setIterations(iterations: Int): ALS

    Set the number of iterations to run.

    Set the number of iterations to run. Default: 10.

  41. def setLambda(lambda: Double): ALS

    Set the regularization parameter, lambda.

    Set the regularization parameter, lambda. Default: 0.01.

  42. def setRank(rank: Int): ALS

    Set the rank of the feature matrices computed (number of features).

    Set the rank of the feature matrices computed (number of features). Default: 10.

  43. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  44. def toString(): String

    Definition Classes
    AnyRef → Any
  45. def unblockFactors(blockedFactors: RDD[(Int, Array[Array[Double]])], outLinks: RDD[(Int, OutLinkBlock)]): RDD[(Int, Array[Double])]

    Flatten out blocked user or product factors into an RDD of (id, factor vector) pairs

  46. def updateBlock(messages: Seq[(Int, Array[Array[Double]])], inLinkBlock: InLinkBlock, rank: Int, lambda: Double, alpha: Double, YtY: Broadcast[Option[DoubleMatrix]]): Array[Array[Double]]

    Compute the new feature vectors for a block of the users matrix given the list of factors it received from each product and its InLinkBlock.

  47. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  48. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  49. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Logging

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped