Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8325391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:25:19+00:00 2026-06-09T00:25:19+00:00

I am trying to use Weka for feature selection using PCA algorithm. My original

  • 0

I am trying to use Weka for feature selection using PCA algorithm.

My original feature space contains ~9000 attributes, in 2700 samples.

I tried to reduce dimensionality of the data using the following code:

AttributeSelection selector = new AttributeSelection();
PrincipalComponents pca = new PrincipalComponents();
Ranker ranker = new Ranker();
selector.setEvaluator(pca);
selector.setSearch(ranker);
Instances instances = SamplesManager.asWekaInstances(trainSet);
try { 
    selector.SelectAttributes(instances);
    return SamplesManager.asSamplesList(selector.reduceDimensionality(instances));
} catch (Exception e ) {
            ...
}

However, It did not finish to run within 12 hours. It is stuck in the method selector.SelectAttributes(instances);.

My questions are:
Is so long computation time expected for weka’s PCA? Or am I using PCA wrongly?

If the long run time is expected:

How can I tune the PCA algorithm to run much faster? Can you suggest an alternative? (+ example code how to use it)?

If it is not:

What am I doing wrong? How should I invoke PCA using weka and get my reduced dimensionality?

Update: The comments confirms my suspicion that it is taking much more time than expected.

I’d like to know: How can I get PCA in java – using weka or an alternative library.

Added a bounty for this one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:25:20+00:00Added an answer on June 9, 2026 at 12:25 am

    After deepening in the WEKA code, the bottle neck is creating the covariance matrix, and then calculating the eigenvectors for this matrix. Even trying to switch to sparsed matrix implementation (I used COLT‘s SparseDoubleMatrix2D) did not help.

    The solution I came up with was first reduce the dimensionality using a first fast method (I used information gain ranker, and filtering based on document frequencey), and then use PCA on the reduced dimensionality to reduce it farther.

    The code is more complex, but it essentially comes down to this:

    Ranker ranker = new Ranker();
    InfoGainAttributeEval ig = new InfoGainAttributeEval();
    Instances instances = SamplesManager.asWekaInstances(trainSet);
    ig.buildEvaluator(instances);
    firstAttributes = ranker.search(ig,instances);
    candidates = Arrays.copyOfRange(firstAttributes, 0, FIRST_SIZE_REDUCTION);
    instances = reduceDimenstions(instances, candidates)
    PrincipalComponents pca = new PrincipalComponents();
    pca.setVarianceCovered(var);
    ranker = new Ranker();
    ranker.setNumToSelect(numFeatures);
    selection = new AttributeSelection();
    selection.setEvaluator(pca);
    selection.setSearch(ranker);
    selection.SelectAttributes(instances );
    instances = selection.reduceDimensionality(wekaInstances);
    

    However, this method scored worse then using a greedy information gain and a ranker, when I cross-validated for estimated accuracy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using weka data mining tool. In weka I am trying to use
I'm trying to use the weka.classifiers.functions.MultilayerPerceptron as classifier on Weka using IKVM.NET but I
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
Anyone know how to create a cvCreateStructuringElementEx using a image? I'm trying use opencv.cv.cvCreateStructuringElementEx()
I'm trying to do a document classification using Weka java API. Here is my
I'm trying to create a new string Attribute using Weka's Java API... Reading through
I was trying use svn to find a checkin using svn log, but it
I'm trying use make a div's background transparent using a mixture of CSS3 rgba()
i am trying to use weka on Android. i need to increase the heapspace
I am trying use the new server side plug-in feature for TFS 2010. (I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.