• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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: 7411
170
  • 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)?
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic