Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Class Index in WEKA?

Tags:

weka

I have to use WEKA in my java code for prediction. Basically I have to study a given code and reuse it.

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

I am unable to understand what the above line means. What is a Class Index?

testdata and data are Intances object.

like image 449
GiriB Avatar asked Nov 04 '14 11:11

GiriB


People also ask

What is a class attribute in Weka?

This type of attribute represents a dynamically expanding set of nominal values. String attributes are not used by the learning schemes in Weka. They can be used, for example, to store an identifier with each instance in a dataset.

What are classifiers in Weka?

A classifier identifies an instance's class, based on a training set of data. Weka makes it very easy to build classifiers. There are many different kinds, and here we use a scheme called “J48” (regrettably a rather obscure name, whose derivation is explained at the end of the video) that produces decision trees.

What is instance in Weka?

java.lang.Object | +----weka.core.Instance public class Instance extends Object implements Copyable, Serializable. Class for handling an instance. All values (numeric, nominal, or string) are internally stored as floating-point numbers.

What is Discretize filter in Weka?

The process of converting a real-valued attribute into an ordinal attribute or bins is called discretization. You can discretize your real valued attributes in Weka using the Discretize filter.


2 Answers

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

Hope this Helps!

like image 101
Matthew Spencer Avatar answered Oct 05 '22 18:10

Matthew Spencer


When you use a classifier to classify a set of data to some class values, you gives an instance which has attributes of the data and an attribute which has the class values. For a example think you have set of e-mails as data, you have to classify those into spam/not-spam. So your class attribute has two class values(spam,not-spam).

Usually, the class attribute add as the last attribute of the instance(not a must). So you have to indicate the classifier which attribute is the class attribute and which are other attributes. So the line you mentioned does this job. Indicating what is the class index of your data instances object.

If you want more explanation, please post your code here. cheers..!

like image 22
Sudheera Avatar answered Oct 05 '22 18:10

Sudheera