Changing attribute values

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

Changing attribute values

hunchbackjack97
Hi there,

I'm currently using the WEKA api to run an experiment involving random
forests. The class value of my data set starts with 8 possible values, e.g.
{1,2,3,4,5,6,7,8}, however in the course of the experiment all the instances
of the classes values 1 - 7 are all set to value1, so the class values are
now {1,1,1,1,1,1,1,8}.
If I try and run this as is I receive the error:

Exception in thread "main" java.lang.IllegalArgumentException: A nominal
attribute (aging) cannot have duplicate labels (1).

So, at present I'm having to complete the first part of the experiment,
manually edit the files so that the class values become {1,8} and then
having to proceed with the second part of the experiment.

Is there a way, using the api and not the GUI, to code this to happen
automatically? I have looked through the methods but can't find anything
that doesn't alter the instances.

Any help is much appreciated.



--
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: Changing attribute values

Peter Reutemann
> I'm currently using the WEKA api to run an experiment involving random
> forests. The class value of my data set starts with 8 possible values, e.g.
> {1,2,3,4,5,6,7,8}, however in the course of the experiment all the instances
> of the classes values 1 - 7 are all set to value1, so the class values are
> now {1,1,1,1,1,1,1,8}.
> If I try and run this as is I receive the error:
>
> Exception in thread "main" java.lang.IllegalArgumentException: A nominal
> attribute (aging) cannot have duplicate labels (1).
>
> So, at present I'm having to complete the first part of the experiment,
> manually edit the files so that the class values become {1,8} and then
> having to proceed with the second part of the experiment.
>
> Is there a way, using the api and not the GUI, to code this to happen
> automatically? I have looked through the methods but can't find anything
> that doesn't alter the instances.

Use the MergeManyValues fiter:
https://weka.sourceforge.io/doc.dev/weka/filters/unsupervised/attribute/MergeManyValues.html

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
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