Skip to content

ENH: Make PCA a class and add features - #2004

Merged
josef-pkt merged 1 commit into
statsmodels:masterfrom
bashtage:pca-class
Jan 12, 2015
Merged

josef-pkt merged 1 commit into
statsmodels:masterfrom
bashtage:pca-class

Conversation

@bashtage

Copy link
Copy Markdown
Member

Encompasses all sandbox PCA routines and added features for plotting, selecting
the number of components and rapidly re-projecting on a subset of factors

@jseabold

Copy link
Copy Markdown
Member

Is it based on this too?

#1596

@bashtage

Copy link
Copy Markdown
Member Author

Some things left to do:

  • Verify example works as expected
  • Translate attribute names for other users, i.e. add explantion that factors are the same as scores , and eigenvals are the same as coefs. Also clarify use of loadings
  • Improve test coverage
  • Basic method to handle missing values using EM algorithm
  • Function version pca
  • plot_scree, plot_rsquare
  • Add option to scree to make cumulative- [x] Incorporate examples/docs from WIP: PCA class #1596
  • NIPALS

@bashtage

Copy link
Copy Markdown
Member Author

I didn't see that when I searched. It has a loose semblance with the code in the sandbox, but adds features popular in econometric applications of factor models like GLS estimation, Information Criteria for selection. and a general interface for user weights.

@jseabold

Copy link
Copy Markdown
Member

Quick comments.

Might want to borrow the use of the existing data handling routines. Also liked that there's also a functional entry point if you want it. We're trying to follow plotting convention for methods with plot_ first, so it's easier to find.

@bashtage bashtage mentioned this pull request Sep 25, 2014
5 of 14 tasks
@bashtage

Copy link
Copy Markdown
Member Author

The function is easy - jut a trivial wrapper around the class. In fact, like yours, the class is a results class, and __init__(...) immediately computes all values.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.16%) when pulling e4a8315 on bashtage:pca-class into 1520fe0 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member

Don't remove the function in the sandbox yet. I still have them i use, and the class might be overkill for the reparameterizations that I have started.

@josef-pkt

Copy link
Copy Markdown
Member

As background to something like the simple pca_svd
I started to work on internal reparameterization tools that don't need data handling and have a very limited requirement, mainly just the linear algebra:
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/base/_constraints.py
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tools/transform_model.py

@bashtage
bashtage force-pushed the pca-class branch 2 times, most recently from 304c5bc to 2dbded4 Compare September 26, 2014 03:17
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.16%) when pulling 2dbded4 on bashtage:pca-class into a4e4eb8 on statsmodels:master.

@jseabold

Copy link
Copy Markdown
Member

Can you cherry-pick and update the notebook (and docs changes around it) and the dataset from #1596?

@bashtage

Copy link
Copy Markdown
Member Author

I plan on it - no need to make work for myself.

@jseabold

Copy link
Copy Markdown
Member

Sure. Just didn't see it in the TODO list. You can close that PR after that.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.07%) when pulling 5d372c4 on bashtage:pca-class into a4e4eb8 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.16%) when pulling 8efe82d on bashtage:pca-class into cfebe9a on statsmodels:master.

@bashtage
bashtage force-pushed the pca-class branch 2 times, most recently from 986201d to c1af11d Compare September 30, 2014 03:15
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) when pulling c1af11d on bashtage:pca-class into cfebe9a on statsmodels:master.

@jseabold

Copy link
Copy Markdown
Member

There are a few PCA class issues. #1238.

@bashtage
bashtage force-pushed the pca-class branch 2 times, most recently from 0105245 to 10e37cd Compare October 1, 2014 10:37
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.18%) when pulling 10e37cd on bashtage:pca-class into cfebe9a on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.18%) when pulling b757908 on bashtage:pca-class into cfebe9a on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.21%) when pulling 2284b2d on bashtage:pca-class into cfebe9a on statsmodels:master.

@bashtage
bashtage force-pushed the pca-class branch 2 times, most recently from 0c2d2aa to bf63322 Compare October 2, 2014 01:29
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling 2c8ffda on bashtage:pca-class into b88f500 on statsmodels:master.

@jseabold

Copy link
Copy Markdown
Member

Did you mean to merge master in to this branch?

@jseabold jseabold added the PR label Nov 20, 2014
@jseabold jseabold added this to the 0.7 milestone Nov 20, 2014
@bashtage

Copy link
Copy Markdown
Member Author

Nope. Should be back after a reset/rebase.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.22%) when pulling 292ada5 on bashtage:pca-class into b878d72 on statsmodels:master.

@jseabold

Copy link
Copy Markdown
Member

Looks good to me. A note in the release notes would be helpful. I can add the notebook to the gallery page unless you want to [1].

[1] http://statsmodels.sourceforge.net/devel/dev/examples.html

@josef-pkt

Copy link
Copy Markdown
Member

Another PR with a single commit and disconnected history. However, in this case I don't really care (much), and I don't think there was much history to loose.

I'm fine with merging this as is, I didn't really look at the details. For now we still need to keep the old sandbox versions around for backwards compatibility and limited use cases, but we might won't to deprecate those, to redirect current sandbox users to this.

Looks very good overall, With the additional features it looks useful for standalone PCA analysis, and might be a good starting point to expand into the multivariate statistical analysis area (with Factor analysis and similar), instead of being a just a tools class, especially with the expanded data handling.

@bashtage can you rebase and force push again, and we hit the green merge button

Thanks

@josef-pkt josef-pkt mentioned this pull request Jan 9, 2015
29 tasks
Encompasses all sandbox PCA routines and added features for plotting, selecting
the number of components and rapidly re-projecting on a subset of factors
@bashtage

Copy link
Copy Markdown
Member Author

Rebased so should be good once green.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.22%) when pulling b954d25 on bashtage:pca-class into 3748bf2 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member

merging

Thanks @bashtage Can you still write a short announcement for the release notes?

josef-pkt added a commit that referenced this pull request Jan 12, 2015
ENH: Make PCA a class and add features
@josef-pkt
josef-pkt merged commit 74f6939 into statsmodels:master Jan 12, 2015
@bashtage

Copy link
Copy Markdown
Member Author

I'll do something tonight.

@bashtage
bashtage deleted the pca-class branch January 12, 2015 15:06
@jseabold

Copy link
Copy Markdown
Member

Release notes blurb/example/sexy graph for this would still be helpful.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants