How to convert instances in arff file to dataset?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to convert instances in arff file to dataset?

anas2020
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



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: How to convert instances in arff file to dataset?

Eibe Frank-2
Administrator
What are “Dataset” and “DefaultDataset”? I’m not familiar with those classes. In standard WEKA, a dataset is represented as an object of type “Instances”. Try using that class instead.

Cheers,
Eibe

> On 16/11/2019, at 10:18 PM, anas2020 <[hidden email]> wrote:
>
> 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
>
>
>
> --
> Sent from: https://weka.8497.n7.nabble.com/
> _______________________________________________
> Wekalist mailing list -- [hidden email]
> Send posts to: To unsubscribe send an email to [hidden email]
> To subscribe, unsubscribe, etc., visit
> https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
> List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html