PySpark-PCA:从模型obj获取组件的数量

2024-04-24 15:12:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我在PySpark中拟合了一个PCA模型,我需要从模型对象中得到组件的数量。你知道吗

from pyspark.ml.feature import PCA
pca = PCA(k=5, inputCol='features', outputCol='components')
pca_model = pca.fit(data)

我试过使用pca_model.kpca_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对象获得组件的数量?你知道吗


Tags: the对象name模型数量docmodelparam