PCA 重构:statsmodels vs sklearn
PCA Reconstruction: statsmodels vs sklearn
我正在尝试将我的 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 和命名法似乎完全不同。
提前致谢!
Statsmodels PCA 实现将数据投影保存为模型属性。
例如,
import statsmodels.api as sm
# specifying two components and fitting data
pca = sm.PCA(X, ncomp=2)
X_reconst = pca.projection
我正在尝试将我的 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 和命名法似乎完全不同。
提前致谢!
Statsmodels PCA 实现将数据投影保存为模型属性。
例如,
import statsmodels.api as sm
# specifying two components and fitting data
pca = sm.PCA(X, ncomp=2)
X_reconst = pca.projection