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 8009751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:32:08+00:00 2026-06-04T18:32:08+00:00

I was trying out the sparse representation of the arff file as shown here

  • 0

I was trying out the sparse representation of the arff file as shown here. In my program I am able to print the the class label “B” but for some reason it is not printing “A”.

    attVals = new FastVector();
    attVals.addElement("A");
    attVals.addElement("B");
    atts.addElement(new Attribute("class", attVals));

    vals[index] = attVals.indexOf("A");

The output for the program is like –

 {0 6,2 8}      ---  I should get {0 6,2 8,3 A}

But when I do

vals[index] = attVals.indexOf("B");

I get proper output –

 {0 6,2 8,3 B}

For some reason it is not taking the index 0. Can someone tell me why this is happening?

  • 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-04T18:32:10+00:00Added an answer on June 4, 2026 at 6:32 pm

    This is a very popular problem. The Sparse format by definition does not store 0 values.

    Weka ARFF format page clearly says that:

    Warning: There is a known problem saving SparseInstance objects from
    datasets that have string attributes. In Weka, string and nominal data
    values are stored as numbers; these numbers act as indexes into an
    array of possible attribute values (this is very efficient). However,
    the first string value is assigned index 0: this means that,
    internally, this value is stored as a 0. When a SparseInstance is
    written, string instances with internal value 0 are not output, so
    their string value is lost (and when the arff file is read again, the
    default value 0 is the index of a different string value, so the
    attribute value appears to change). To get around this problem, add a
    dummy string value at index 0 that is never used whenever you declare
    string attributes that are likely to be used in SparseInstance objects
    and saved as Sparse ARFF files.

    You have to put a dummy attribute in the first place. Just modify your code to:

    attVals = new FastVector();
    attVals.addElement("dummy");
    attVals.addElement("A");
    attVals.addElement("B");
    

    Let me know if you need any further help.

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

Sidebar

Related Questions

I'm trying to load some decimal values from a file but I can't work
Trying out the example usage of codebrew rails-backbone , everything works fine but the
Trying out the examples found on pleac.sf.net , I'm not able to get an
I am trying out some examples with analytical functions and i have created a
I'm trying to do a sparse checkout of a folder containing externals, but none
I'm trying to cluster some data with python and scipy but the following code
Trying out VS 2010, but still want to target .NET 3.5. Have all my
Trying out some things with php and html, I'm having issues trying to get
Im trying out the banking sample application and when i try to add or
While trying out an experimental UINavigationController-based iPhone application, I ran into a problem when

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.