What is a class index in WEKA?

I need to use WEKA in my Java code for forecasting. Basically, I have to study this code and reuse it.

testdata.setClassIndex(data.numAttributes() - 1);

I can not understand what the above line means. What is a class index?

testdata and data are Intances objects.

+6
source share
3 answers

As indicated here , setClassIndex is used to determine the attribute that the class will represent (for forecasting purposes). Given that the index starts at zero, data.numAttributes () - 1 represents the last attribute of the testdata set.

Hope this helps!

+8
source

When you use a classifier to classify a dataset for some class values, you get an instance that has data attributes and an attribute that has class values. For example, if you have a set of emails as data, you should classify them as spam / non-spam. So your class attribute has two class values ​​(spam, non-spam).

Typically, a class attribute is added as the last attribute of the instance (optional). Therefore, you must specify a classifier whose attribute is an attribute of the class and which are other attributes. So the line you specified does the job. Indicates what the class index of your data instance object is.

If you need more explanation, write your code here. Hooray!..

+3
source

The class index indicates the target attribute used for classification. By default, in the ARFF file, this is the last attribute that explains why it sets numAttributes-1.

0
source

Source: https://habr.com/ru/post/977707/


All Articles