【问题标题】:PCA Reconstruction: statsmodels vs sklearnPCA 重建:statsmodels 与 sklearn
【发布时间】:2019-10-06 17:53:27
【问题描述】:

我正在尝试将我的 PCA 模型从 sklearn 移动到 statmodels。

使用 sklearn,我可以通过以下方式重建我的数据:

# reconstruction using 2 principal components
pca = PCA(n_components=2)
pca.fit(X)

# reconstruct the data
X_reconst = np.dot(pca.transform(X)[:,:2], pca.components_[:2,:])

statsmodels 中执行相同操作的效果是什么? API 和命名法似乎完全不同。

提前致谢!

【问题讨论】:

  • 这里的fa 是什么?
  • @MohammedKashif 对不起,只是一个错误..

标签: python scikit-learn statsmodels


【解决方案1】:

Statsmodels PCA 实现将数据的投影保存为模型属性。

例如,

import statsmodels.api as sm

# specifying two components and fitting data
pca = sm.PCA(X, ncomp=2)
X_reconst = pca.projection

【讨论】:

    猜你喜欢
    • 2016-12-12
    • 1970-01-01
    • 2021-03-24
    • 1970-01-01
    • 2017-07-19
    • 2015-09-27
    • 2019-04-03
    • 2020-12-22
    • 1970-01-01
    相关资源
    最近更新 更多