EducationalTestingService / EducationalTestingService/factor_analyzer

Loadings matrix has incorrect shape when using principal method with lapack

Đang mở
#137 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
6
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.