Skip to content

Add Varimax rotation for Factor Analysis and PCA #2688

Closed

Description

@dfrusdn

Activity

  1. agramfort commented on Dec 25, 2013

    @agramfort
    Member

    it's indeed a well known method that can offer some insights on data. A
    gist with a good illustrative example would be a start to see if it's
    conclusive. If so, a PR can be started.

    Can you draft the gist?

  2. dengemann commented on Dec 26, 2013

    @dengemann
    Contributor

    Okay, I'm going to take a look.

  3. rossfadely commented on Jan 15, 2014

    @rossfadely
  4. mvds314 commented on Mar 1, 2016

    @mvds314

    I recently put some code on Github for factor ration under a BSD license.

  5. robkoper commented on Apr 30, 2016

    @robkoper

    This is already an old topic, but FA needs rotation methods and it is still not implemented in scikit learn. Are there any concrete plans to implement the code above?

  6. agramfort commented on Apr 30, 2016

    @agramfort
    Member
  7. mvds314 commented on Apr 30, 2016

    @mvds314

    Examples and documentation are included in the factor rotation code I put on Github. Since a whole bunch of ration methods are supported, it is a bit more code though.

  8. TheChymera commented on Jun 20, 2016

    @TheChymera

    @mvds314 sadly I wouldn't know how to rewrite your code for scikit_learn - but I would also be very happy if this feature became available. If you need any sort of testing I can try to help.

  9. amueller commented on Oct 11, 2016

    @amueller
    Member

    Should this be an option of PCA and FA? (I guess ICA wouldn't make sense).
    Or should this be a stand-alone model?

    @mvds314 your example doesn't really explain what's happening. I think we're still open to a more full-fledged example.

  10. mvds314 commented on Oct 12, 2016

    @mvds314

    @amueller: If I understand you correctly, the example shows how the code works, but you want to understand what happens. This is explained in detail in docstring of the rotate factors function. This file also contains some references to papers. The short summary is that the factors are rotated according to some criterion. The criterion that is minimized is explained in the docstring. The minimization procedure itself is numerical and the the algorithm for this is explained in the references also mentioned in the docstring.

    I hope this helps!

  11. robkoper commented on Oct 12, 2016

    @robkoper

    @amueller 'Should this be an option of PCA and FA? '
    I would prefer the code to be available to both, although there is a debate about the question whether the result of rotated PCA is still PCA. But this is largely a dispute about the definitions of PCA and FA. See for more info this post: http://stats.stackexchange.com/questions/612/is-pca-followed-by-a-rotation-such-as-varimax-still-pca

  12. 22 remaining items

  13. Akumenyi commented on Sep 26, 2018

    @Akumenyi

    @jona-sassenhagen sorry for the lack of clarity; i get a type error;

    TypeError Traceback (most recent call last)
    for ax, method in zip(axes, (None, 'varimax')):
    ----> fa = FactorAnalysis(n_components=n_comps, method= 'varimax').fit(X)
    components = fa.components_.T

    TypeError: init() got an unexpected keyword argument 'method'

  14. jona-sassenhagen commented on Sep 26, 2018

    @jona-sassenhagen
    Contributor

    Ok, that's cause the code in #11064 is not yet merged. You could pull that branch and it should work.

  15. Akumenyi commented on Sep 26, 2018

    @Akumenyi

    @jona-sassenhagen apologies. how do I do that?

  16. jona-sassenhagen commented on Sep 26, 2018

    @jona-sassenhagen
    Contributor

    Sorry, I'm not competent to give you an intro to git. You will have to familiarise yourself with git a bit by your own. Then purge your current sklearn, install sklearn from GitHub, add my repo, and do this: https://stackoverflow.com/questions/1709177/git-pull-a-certain-branch-from-github

  17. Akumenyi commented on Sep 27, 2018

    @Akumenyi

    @jona-sassenhagen thanks for the help.

  18. Akumenyi commented on Oct 1, 2018

    @Akumenyi

    @jona-sassenhagen I have been able to clone the master branch of Scikit-learn from your repository and installed on my machine but the rotation option from FactorAnalysis is not there.

    Do I need to do anything else to add that functionality? Can you confirm if the version of the FactorAnalysis function with rotation is in the master branch?

    Thanks
    Kwesi

  19. jona-sassenhagen commented on Oct 1, 2018

    @jona-sassenhagen
    Contributor

    It's not in the master branch - it's in jona-sassenhagen:varimax

  20. jona-sassenhagen commented on Oct 1, 2018

    @jona-sassenhagen
    Contributor

    see here: #11064

  21. Akumenyi commented on Oct 1, 2018

    @Akumenyi

    @jona-sassenhagen Thanks! I have finally been able to get to work.

    For future beginners of git;

    All I did was to install scikit-learn from @jona-sassenhagen repository then
    git checkout -b origin/varimax and
    python setup.py install

    Cheers!

  22. ptgoff commented on May 19, 2021

    @ptgoff

    @amueller 'Should this be an option of PCA and FA? '
    I would prefer the code to be available to both, although there is a debate about the question whether the result of rotated PCA is still PCA. But this is largely a dispute about the definitions of PCA and FA. See for more info this post: http://stats.stackexchange.com/questions/612/is-pca-followed-by-a-rotation-such-as-varimax-still-pca

    Here is an excellent paper (2020) that addresses the need for rotation (varimax) following PCA. https://arxiv.org/abs/2004.05387

  23. tatopane commented on Oct 21, 2021

    @tatopane

    Hi, is there a reason why this was implemented in FA but not in PCA, apart from the comment above?

    I need to do PCA and then varimax, is there a known workaround? (I googled a lot but couldn't find the answer)

    Thanks

  24. huaracheguarache commented on Nov 24, 2022

    @huaracheguarache

    I would also really like to see this implemented for PCA.

  25. keyber commented on May 4, 2024

    @keyber
    Contributor

    The drawbacks of using an orthogonal rotation (such as Varimax) after a PCA are :

    1. We lose the variance-maximizing properties of PCA (optimal variance explanation in the first components).
      This property is essential to extract the top k components.
      However, once the components are extracted, this property becomes much less relevant.
      The rotation can be applied after the component extraction (the amount of explained variance will remain the same).
      So this point is not very troublesome.

    2. The axes are not orthogonal anymore
      Even though the axes are initially orthogonal and the Varimax rotation is also orthogonal, the resulting axes are not (it is not the axes that are rotated by the Varimax rotation https://stats.stackexchange.com/a/136936).
      If I understand correctly, this means that the features we obtain could be correlated.

    Another alternative would be to use SparsePCA , but SparsePCA also suffers from non-orthogonality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions