EducationalTestingService / EducationalTestingService/factor_analyzer
Loadings matrix has incorrect shape when using principal method with lapack
- 主要语言
- Python
- 星标
- 6
- 派生
- 1
- PR 合并指标
- 30 天内没有已合并 PR
描述
**Bug Description**
When using the principal method with lapack SVD instead of randomized, the loadings matrix returned by FactorAnalyzer is always given in full, it has shape n_cols x n_cols, instead of selecting only loadings for the n_factors desired. When using the randomized SVD, there is no issue.
**Reproducible Code**
```
import pandas as pd
import numpy as np
num_rows = 1000
num_cols = 6
df = pd.DataFrame(
np.random.standard_normal(size=(num_rows, num_cols)),
columns=[f'col{i+1}' for i in range(num_cols)])
# shape is correct with randomized
efa = FactorAnalyzer(n_factors=2, rotation='promax', method='principal', svd_method='randomized')
efa.fit(df)
print(efa.loadings_.shape)
# shape is incorrect with lapack
efa = FactorAnalyzer(n_factors=2, rotation='promax', method='principal', svd_method='lapack')
efa.fit(df)
print(efa.loadings_.shape)
```
**Expected behavior**
The shape of the .loadings_ attribute should be n_cols x n_factors.
**Versions (please complete the following information):**
- OS: Windows 10
- Python: 3.10.10
- Versions for `factor_analyzer`: 0.5.1 / `numpy`: 1.26.1 / `scipy` : 1.11.3 / `pandas`: 2.1.1
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先运行使用 method='principal' 和两种 svd_method 值的可复现 FactorAnalyzer 示例,然后检查生成 loadings_ 的 FactorAnalyzer.fit 路径。确认 lapack 结果的形状为 n_cols x n_factors,与 randomized 结果一致,并符合预期行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- numpy, pandas, python
- 领域
- data
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 48/100