python sklearn.decomposition FactorAnalysis函数

2024-09-27 22:19:54 发布

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

我正在使用sklearn.decomposition FactorAnalysis对我的股票收益矩阵(200*676)进行因子分析,我有三个函数:fit、transform和transform\u fit,应该选择哪一个 我过去常常得到因子载荷


Tags: 函数transform矩阵sklearn收益因子fit股票
1条回答
网友
1楼 · 发布于 2024-09-27 22:19:54

我猜是components_是因子载荷。我以前只在R中应用过这个算法。我不确定这是Python中的加载。作为检查,荷载应满足方程式Cov = LL^T + Sigma。在python中,它是

from sklearn.decomposition import FactorAnalysis
fa = FactorAnalysis(n_components=k, random_state=0)

# Check the dimension
# It should be (n_features, n_components)
fa.components_.T.shape

# Check equation
# It should be all True
fa.components_.T @ fa.components_ + np.diag(fa.noise_variance_) == fa.get_covariance()

有关更多详细信息,请参阅本文件https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.FactorAnalysis.html#sklearn.decomposition.FactorAnalysis

相关问题 更多 >

    热门问题