Loadings matrix has incorrect shape when using principal method with lapack
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
Research direction
Start by running the reproducible FactorAnalyzer examples with method='principal' and both svd_method values, then inspect the FactorAnalyzer.fit path that produces loadings_. Confirm that the lapack result has shape n_cols x n_factors, matching the randomized result and the expected behavior.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 6
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from EducationalTestingService/factor_analyzer
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
EducationalTestingService/factor_analyzer#148 · 4 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
EducationalTestingService/factor_analyzer#147 · 1 reaction ·
-
Order of variables when DF is fed to fit with CFA: either document or actually use the column names? Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
EducationalTestingService/factor_analyzer#146 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
EducationalTestingService/factor_analyzer#145 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
All issues in EducationalTestingService/factor_analyzer
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100