【发布时间】:2018-05-22 17:12:34
【问题描述】:
我在 PySpark 中有一个适合的 PCA 模型,我需要从模型对象中获取组件的数量。
from pyspark.ml.feature import PCA
pca = PCA(k=5, inputCol='features', outputCol='components')
pca_model = pca.fit(data)
我尝试使用pca_model.k 和pca_model.getParam('k'),但它们都没有给出组件的数量。
>>> pca_model.k
Param(parent='PCA_4e66a98132a4fe4ad86c', name='k', doc='the number of principal components (> 0)')
>>> pca_model.getParam('k')
Param(parent='PCA_4e66a98132a4fe4ad86c', name='k', doc='the number of principal components (> 0)')
如何从 PySpark 的 PCAModel 对象中获取组件的数量?
【问题讨论】:
标签: python apache-spark pyspark apache-spark-ml