• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to convert instances in arff file to dataset?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am trying to convert instances that are read from arff file to dataset but I could not because the dataset did not accept the type instances. The following code is used

   ArffLoader loader = new ArffLoader();
           loader.setSource(new File("aldlon.arff"));
           input_data = loader.getDataSet();
           input_data.setClassIndex(input_data.numAttributes()-1);
           String[] options = new String[2];
            options[0] = "-R";                                    
            options[1] = AllBestfeatures;                                    
            Remove remove = new Remove();                  
            remove.setOptions(options);                        
            remove.setInvertSelection(new Boolean(true).booleanValue());
            remove.setInputFormat(input_data);  
            Instances newData2 = Filter.useFilter(input_data, remove);
Dataset newdata1 = new DefaultDataset();
       for (int i =0; i <newData2.numInstances(); ++i) {
    //  System.out.println("the training data " + newData2.instance(i));
   newdata1.add(newData2.instance(i));
   }
the error in the last line of the code in which the newdata1 did not accept type of dataset.

any help please
 
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What API is this? How have you verified that the file is valid ARFF file (whatever that is)?
reply
    Bookmark Topic Watch Topic
  • New Topic