cstjean / ScikitLearn.jl

Julia implementation of the scikit-learn API https://cstjean.github.io/ScikitLearn.jl/dev/
Other
546 stars 75 forks source link

PCA has wrong dimensions #61

Closed kavir1698 closed 5 years ago

kavir1698 commented 5 years ago

In the following example, there are 10 samples and 5 features. The output should have 10 samples and 2 features, but it has 5 samples:

using ScikitLearn
import ScikitLearn: fit!
@sk_import decomposition: PCA

X = rand(10, 5)
pca = PCA(n_components=2)
fit!(pca, X)
pca.components_

2×5 Array{Float64,2}:
 0.670536  -0.26009   0.325406  -0.324582   0.521049
 0.411367   0.360626  0.461346   0.66101   -0.225726
cstjean commented 5 years ago

There are two components, each of which has 5 features. Isn't that what you see?

I think you're thinking about the transformed output. IIRC you can do transform(pca, X) after fitting to get those.

kavir1698 commented 5 years ago

Thanks for your reply. True, my mistake. I close the issue now.