I would like to do PCA for my dataset using weka's PCA. I saw online the java code is:
I import both import weka.attributeSelection.PrincipalComponents and import weka.filters.Filter in the code, but eclipse always shows that in the third line, pca need to be cast to Filter. After I cast pca to Filter, it is still wrong. The fourth line is also showed wrong. I would like to know what is the right code to do pca for an existing dataset?
Thanks!
The problem you're running into is that there are two classes called PrincipalComponents
in the weka API:
weka.attributeSelection.PrincipalComponents
and weka.filters.unsupervised.attribute.PrincipalComponents
.
The latter is a kind of Filter
, but you are importing the former, which is not.
Just change your import statement and your code should work.