Weka Experimenter 'Class attribute is not nominal' but data is processed from Explorer
Solution 1
If your class attribute is numeric (like 0,1) change it to a nominal form like true
, false
.
Solution 2
In my case, there were nominal attributes in the file. However, Weka expects these to be last, since they indicate the class that the record is being assigned to. Here's how I rearranged the data so that the nominal value was last:
- In Explorer, open the arff file.
- Click 'Edit...' then find the column which should be the class of each record.
- Right click on the column header and select 'Attribute as class'.
- Click 'Save...' and use this new dataset in Experimenter.
Works like a charm.
Reily Bourne
Updated on June 05, 2022Comments
-
Reily Bourne almost 2 years
Good Evening,
I am working on a supervised classification task. I have a big arff file full of data in the format, "text", class. There are only two classes, E and I.
I can load this data into Weka Explorer, apply the StringToWordVector with TF-IDF on it, then using LibSVM classify it and get results. But I need to use 5x2 Cross-Validation and get the Area under the ROC Curve. So I save that processed data, open up Weka Experimenter, load it in, set it to 2 folds, 5 iterations, and then set the algorithm to libSVM.
When I go to the RUN tab and press start I get the following error:
18:31:18: Started
18:31:18: Class attribute is not nominal!
18:31:18: Interrupted
18:31:18: There was 1 error
I don't know why this is happening, what exactly the error is, or how to fix it. I google this error and it is not leading me to any solutions. I am not sure where I should go from here to fix this.
I can go back to Explorer, reload in that processed file, and classify it without any issues but I need to do it in Experimenter.
-
Sentry over 10 yearsThis is maybe a bit too late, but it is not possible with the currently available LibSVM classifiers for Weka to get the correct AUC values, unless you use the LibSVM with class probabilities. AUC and accuracy are always the same otherwise.
-
-
Reily Bourne over 11 yearsIn my data.arff file there are only two @attributes, message which is a string and Class which is {E, I}. My data is in the format "foo bar text", E or "foo bar text", I. I load this into weka, can preprocess it with the supervised attribute filter StringToWordVector and save that as dataSTWV.arff. I can reload this into Explorer and it works but loading dataSTWV into Experimenter is what is giving me that error. Weka is defining the class atrribute in that file. How can I change it to nominal true and false?
-
hkn over 11 yearsWhat is the header of the generated file dataSTWV.arff? You can open it with any text editor. If the attribute definition is numeric like \@attribute myclass numeric, then you should change it to something like \@attribute myclass {0,1} where 0 and 1 are the distinct values for that attribute. Or you can find/replace to something like true/false and update the \@attribute definition.
-
hkn over 11 yearsSO does not let me use '@' alone so I added \ before them.
-
Reily Bourne over 11 yearsIll look into that this evening when I get back to my work computer. I've also did some more googling and found the NumericToNominal (and possibly Discretize) functions. I will let you know if this works.
-
Reily Bourne over 11 yearsI think you helped me solve it... sort of. By applying the NumericToNominal filter on the class as well as the StringToWordVector it is loading and working in Experimenter. It changes the of the first two attributes is \@attribute Class {E,I} \@attribute 0 numeric to \@attribute Class {E,I} \@attribute 0 {0,2.295817} though I am not sure if it matters which order the filters are applied
-
Muhammad Noman over 6 yearsThe Experimenter uses the last attribute in the data as the class attribute. If the last attribute is not nominal you will get this error.