【问题标题】:I did dimension reduction using PCA model on Spark, but it errors as follows:我在 Spark 上使用 PCA 模型进行了降维,但错误如下:
【发布时间】:2023-03-05 03:58:01
【问题描述】:
16/01/13 15:34:07 INFO DAGScheduler: Job 3 finished: first at RowMatrix.scala:65, took 0.013421 s
Exception in thread "main" java.lang.IllegalArgumentException: Argument with more than 65535 cols: 262144
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.checkNumColumns(RowMatrix.scala:135)
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeCovariance(RowMatrix.scala:330)
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.computePrincipalComponents(RowMatrix.scala:386)
    at org.apache.spark.mllib.feature.PCA.fit(PCA.scala:46)
    at org.apache.spark.mllib.clustering.KMeansPca$delayedInit$body.apply(KMeansPca.scala:41)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:71)
    at scala.App$$anonfun$main$1.apply(App.scala:71)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
    at scala.App$class.main(App.scala:71)
    at org.apache.spark.mllib.clustering.KMeansPca$.main(KMeansPca.scala:12)
    at org.apache.spark.mllib.clustering.KMeansPca.main(KMeansPca.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
16/01/13 15:34:07 INFO SparkContext: Invoking stop() from shutdown hook
16/

我该如何解决这个问题?

【问题讨论】:

    标签: apache-spark pca


    【解决方案1】:

    错误表示您传递的 Matrix 列过多(超过 65535)。

    检查代码 here 并注意他们说“请注意,这不能在超过 65535 列的矩阵上计算。”

    因此,您必须确保矩阵中的列数不超过 65535。

    【讨论】:

    • 但是如何在超过 65535 列的矩阵上训练 PCA 模型。您知道,在文本分析中,将文本表示为具有大列的矩阵是很常见的。
    • 我不认为这是可能的,但我可能错了。我能想到的解决方案是过滤文本以减少您的词汇量(消除停用词、词干、消除低 DF 的词......)
    • 非常感谢,我会试试的。
    猜你喜欢
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 2022-09-30
    • 1970-01-01
    • 2015-02-28
    • 2018-04-15
    • 2017-08-05
    • 2013-03-06
    相关资源
    最近更新 更多