Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package apache
    Definition Classes
    org
  • package spark

    Core Spark functionality.

    Core Spark functionality. org.apache.spark.SparkContext serves as the main entry point to Spark, while org.apache.spark.rdd.RDD is the data type representing a distributed collection, and provides most parallel operations.

    In addition, org.apache.spark.rdd.PairRDDFunctions contains operations available only on RDDs of key-value pairs, such as groupByKey and join; org.apache.spark.rdd.DoubleRDDFunctions contains operations available only on RDDs of Doubles; and org.apache.spark.rdd.SequenceFileRDDFunctions contains operations available on RDDs that can be saved as SequenceFiles. These operations are automatically available on any RDD of the right type (e.g. RDD[(Int, Int)] through implicit conversions.

    Java programmers should reference the org.apache.spark.api.java package for Spark programming APIs in Java.

    Classes and methods marked with Experimental are user-facing features which have not been officially adopted by the Spark project. These are subject to change or removal in minor releases.

    Classes and methods marked with Developer API are intended for advanced users want to extend Spark through lower level interfaces. These are subject to changes or removal in minor releases.

    Definition Classes
    apache
  • package mllib

    RDD-based machine learning APIs (in maintenance mode).

    RDD-based machine learning APIs (in maintenance mode).

    The spark.mllib package is in maintenance mode as of the Spark 2.0.0 release to encourage migration to the DataFrame-based APIs under the org.apache.spark.ml package. While in maintenance mode,

    • no new features in the RDD-based spark.mllib package will be accepted, unless they block implementing new features in the DataFrame-based spark.ml package;
    • bug fixes in the RDD-based APIs will still be accepted.

    The developers will continue adding more features to the DataFrame-based APIs in the 2.x series to reach feature parity with the RDD-based APIs. And once we reach feature parity, this package will be deprecated.

    Definition Classes
    spark
    See also

    SPARK-4591 to track the progress of feature parity

  • package linalg
    Definition Classes
    mllib
  • package distributed
    Definition Classes
    linalg
  • BlockMatrix
  • CoordinateMatrix
  • DistributedMatrix
  • IndexedRow
  • IndexedRowMatrix
  • MatrixEntry
  • RowMatrix

class RowMatrix extends DistributedMatrix with Logging

Represents a row-oriented distributed Matrix with no meaningful row indices.

Annotations
@Since( "1.0.0" )
Source
RowMatrix.scala
Linear Supertypes
Logging, DistributedMatrix, Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RowMatrix
  2. Logging
  3. DistributedMatrix
  4. Serializable
  5. Serializable
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new RowMatrix(rows: RDD[Vector])

    Alternative constructor leaving matrix dimensions to be determined automatically.

    Alternative constructor leaving matrix dimensions to be determined automatically.

    Annotations
    @Since( "1.0.0" )
  2. new RowMatrix(rows: RDD[Vector], nRows: Long, nCols: Int)

    rows

    rows stored as an RDD[Vector]

    nRows

    number of rows. A non-positive value means unknown, and then the number of rows will be determined by the number of records in the RDD rows.

    nCols

    number of columns. A non-positive value means unknown, and then the number of columns will be determined by the size of the first row.

    Annotations
    @Since( "1.0.0" )

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @IntrinsicCandidate()
  6. def columnSimilarities(threshold: Double): CoordinateMatrix

    Compute similarities between columns of this matrix using a sampling approach.

    Compute similarities between columns of this matrix using a sampling approach.

    The threshold parameter is a trade-off knob between estimate quality and computational cost.

    Setting a threshold of 0 guarantees deterministic correct results, but comes at exactly the same cost as the brute-force approach. Setting the threshold to positive values incurs strictly less computational cost than the brute-force approach, however the similarities computed will be estimates.

    The sampling guarantees relative-error correctness for those pairs of columns that have similarity greater than the given similarity threshold.

    To describe the guarantee, we set some notation: Let A be the smallest in magnitude non-zero element of this matrix. Let B be the largest in magnitude non-zero element of this matrix. Let L be the maximum number of non-zeros per row.

    For example, for {0,1} matrices: A=B=1. Another example, for the Netflix matrix: A=1, B=5

    For those column pairs that are above the threshold, the computed similarity is correct to within 20% relative error with probability at least 1 - (0.981)10/B

    The shuffle size is bounded by the *smaller* of the following two expressions:

    O(n log(n) L / (threshold * A)) O(m L2)

    The latter is the cost of the brute-force approach, so for non-zero thresholds, the cost is always cheaper than the brute-force approach.

    threshold

    Set to 0 for deterministic guaranteed correctness. Similarities above this threshold are estimated with the cost vs estimate quality trade-off described above.

    returns

    An n x n sparse upper-triangular matrix of cosine similarities between columns of this matrix.

    Annotations
    @Since( "1.2.0" )
  7. def columnSimilarities(): CoordinateMatrix

    Compute all cosine similarities between columns of this matrix using the brute-force approach of computing normalized dot products.

    Compute all cosine similarities between columns of this matrix using the brute-force approach of computing normalized dot products.

    returns

    An n x n sparse upper-triangular matrix of cosine similarities between columns of this matrix.

    Annotations
    @Since( "1.2.0" )
  8. def computeColumnSummaryStatistics(): MultivariateStatisticalSummary

    Computes column-wise summary statistics.

    Computes column-wise summary statistics.

    Annotations
    @Since( "1.0.0" )
  9. def computeCovariance(): Matrix

    Computes the covariance matrix, treating each row as an observation.

    Computes the covariance matrix, treating each row as an observation.

    returns

    a local dense matrix of size n x n

    Annotations
    @Since( "1.0.0" )
    Note

    This cannot be computed on matrices with more than 65535 columns.

  10. def computeGramianMatrix(): Matrix

    Computes the Gramian matrix A^T A.

    Computes the Gramian matrix A^T A.

    Annotations
    @Since( "1.0.0" )
    Note

    This cannot be computed on matrices with more than 65535 columns.

  11. def computePrincipalComponents(k: Int): Matrix

    Computes the top k principal components only.

    Computes the top k principal components only.

    k

    number of top principal components.

    returns

    a matrix of size n-by-k, whose columns are principal components

    Annotations
    @Since( "1.0.0" )
    See also

    computePrincipalComponentsAndExplainedVariance

  12. def computePrincipalComponentsAndExplainedVariance(k: Int): (Matrix, Vector)

    Computes the top k principal components and a vector of proportions of variance explained by each principal component.

    Computes the top k principal components and a vector of proportions of variance explained by each principal component. Rows correspond to observations and columns correspond to variables. The principal components are stored a local matrix of size n-by-k. Each column corresponds for one principal component, and the columns are in descending order of component variance. The row data do not need to be "centered" first; it is not necessary for the mean of each column to be 0. But, if the number of columns are more than 65535, then the data need to be "centered".

    k

    number of top principal components.

    returns

    a matrix of size n-by-k, whose columns are principal components, and a vector of values which indicate how much variance each principal component explains

    Annotations
    @Since( "1.6.0" )
  13. def computeSVD(k: Int, computeU: Boolean = false, rCond: Double = 1e-9): SingularValueDecomposition[RowMatrix, Matrix]

    Computes singular value decomposition of this matrix.

    Computes singular value decomposition of this matrix. Denote this matrix by A (m x n). This will compute matrices U, S, V such that A ~= U * S * V', where S contains the leading k singular values, U and V contain the corresponding singular vectors.

    At most k largest non-zero singular values and associated vectors are returned. If there are k such values, then the dimensions of the return will be:

    • U is a RowMatrix of size m x k that satisfies U' * U = eye(k),
    • s is a Vector of size k, holding the singular values in descending order,
    • V is a Matrix of size n x k that satisfies V' * V = eye(k).

    We assume n is smaller than m, though this is not strictly required. The singular values and the right singular vectors are derived from the eigenvalues and the eigenvectors of the Gramian matrix A' * A. U, the matrix storing the right singular vectors, is computed via matrix multiplication as U = A * (V * S-1), if requested by user. The actual method to use is determined automatically based on the cost:

    • If n is small (n < 100) or k is large compared with n (k > n / 2), we compute the Gramian matrix first and then compute its top eigenvalues and eigenvectors locally on the driver. This requires a single pass with O(n2) storage on each executor and on the driver, and O(n2 k) time on the driver.
    • Otherwise, we compute (A' * A) * v in a distributive way and send it to ARPACK's DSAUPD to compute (A' * A)'s top eigenvalues and eigenvectors on the driver node. This requires O(k) passes, O(n) storage on each executor, and O(n k) storage on the driver.

    Several internal parameters are set to default values. The reciprocal condition number rCond is set to 1e-9. All singular values smaller than rCond * sigma(0) are treated as zeros, where sigma(0) is the largest singular value. The maximum number of Arnoldi update iterations for ARPACK is set to 300 or k * 3, whichever is larger. The numerical tolerance for ARPACK's eigen-decomposition is set to 1e-10.

    k

    number of leading singular values to keep (0 < k <= n). It might return less than k if there are numerically zero singular values or there are not enough Ritz values converged before the maximum number of Arnoldi update iterations is reached (in case that matrix A is ill-conditioned).

    computeU

    whether to compute U

    rCond

    the reciprocal condition number. All singular values smaller than rCond * sigma(0) are treated as zero, where sigma(0) is the largest singular value.

    returns

    SingularValueDecomposition(U, s, V). U = null if computeU = false.

    Annotations
    @Since( "1.0.0" )
    Note

    The conditions that decide which method to use internally and the default parameters are subject to change.

  14. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  16. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  18. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  19. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  20. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  21. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  22. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  23. def logDebug(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  24. def logDebug(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  25. def logError(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  26. def logError(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  27. def logInfo(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  28. def logInfo(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  29. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  30. def logTrace(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  31. def logTrace(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  32. def logWarning(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  33. def logWarning(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  34. def multiply(B: Matrix): RowMatrix

    Multiply this matrix by a local matrix on the right.

    Multiply this matrix by a local matrix on the right.

    B

    a local matrix whose number of rows must match the number of columns of this matrix

    returns

    a org.apache.spark.mllib.linalg.distributed.RowMatrix representing the product, which preserves partitioning

    Annotations
    @Since( "1.0.0" )
  35. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  36. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  37. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  38. def numCols(): Long

    Gets or computes the number of columns.

    Gets or computes the number of columns.

    Definition Classes
    RowMatrixDistributedMatrix
    Annotations
    @Since( "1.0.0" )
  39. def numRows(): Long

    Gets or computes the number of rows.

    Gets or computes the number of rows.

    Definition Classes
    RowMatrixDistributedMatrix
    Annotations
    @Since( "1.0.0" )
  40. val rows: RDD[Vector]
    Annotations
    @Since( "1.0.0" )
  41. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  42. def tallSkinnyQR(computeQ: Boolean = false): QRDecomposition[RowMatrix, Matrix]

    Compute QR decomposition for RowMatrix.

    Compute QR decomposition for RowMatrix. The implementation is designed to optimize the QR decomposition (factorization) for the RowMatrix of a tall and skinny shape. Reference: Paul G. Constantine, David F. Gleich. "Tall and skinny QR factorizations in MapReduce architectures" (see here)

    computeQ

    whether to computeQ

    returns

    QRDecomposition(Q, R), Q = null if computeQ = false.

    Annotations
    @Since( "1.5.0" )
  43. def toString(): String
    Definition Classes
    AnyRef → Any
  44. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  46. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from Logging

Inherited from DistributedMatrix

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped