You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dong Wang (Jira)" <ji...@apache.org> on 2019/11/09 13:03:00 UTC

[jira] [Created] (SPARK-29814) Missing persist on sources in mllib.feature.PCA

Dong Wang created SPARK-29814:
---------------------------------

             Summary: Missing persist on sources in mllib.feature.PCA
                 Key: SPARK-29814
                 URL: https://issues.apache.org/jira/browse/SPARK-29814
             Project: Spark
          Issue Type: Improvement
          Components: MLlib
    Affects Versions: 2.4.3
            Reporter: Dong Wang


The rdd is used in more than one actions: first() and actions in computePrincipalComponentsAndExplainedVariance(), so it needs to be persisted.

{code:scala}
  def fit(sources: RDD[Vector]): PCAModel = {
    // first use rdd sources on action first()
    val numFeatures = sources.first().size
    require(k <= numFeatures,
      s"source vector size $numFeatures must be no less than k=$k")
    require(PCAUtil.memoryCost(k, numFeatures) < Int.MaxValue,
      "The param k and numFeatures is too large for SVD computation. " +
      "Try reducing the parameter k for PCA, or reduce the input feature " +
      "vector dimension to make this tractable.")

    val mat = new RowMatrix(sources)
    // second use rdd sources
    val (pc, explainedVariance) = mat.computePrincipalComponentsAndExplainedVariance(k)
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org