Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fit PCA on covariance #1

Open
keyuchen886 opened this issue Jun 2, 2020 · 1 comment
Open

fit PCA on covariance #1

keyuchen886 opened this issue Jun 2, 2020 · 1 comment

Comments

@keyuchen886
Copy link

In your ml.py file, line 67 you have the following:

Creating covariance matrix and training data on PCA.

cov_matrix = X_train.loc[:,X_train.columns != 'DJIA'].cov()
pca = PCA()
pca.fit(cov_matrix)

I am just wondering why do you fit pca on the covariance matrix instead of the original returns?
According to the original paper(page 7), the author fits eigen decomposition on the covariance. In your code, using pca to fit will result in computing covariance twice and then do eigen decomposition, which I think will be a problem.

@caretak3r
Copy link

@keyuchen886 did you ever figure out the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants