java - Weka unlabeled attribute...does it has to be part of the Instance to get classified? -
easy , fast doubt. lets arff looks this:
@attribute outlook { sunny, overcast, rainy } @attribute temperature numeric @attribute humidity numeric @attribute windy { true, false } @attribute play { yes, no } @data sunny, 85, 85, false, no sunny, 80, 90, true, no overcast, 83, 86, false, yes rainy, 70, 96, false, yes rainy, 68, 80, false, yes ......
5 attributes (4 without class attribute). when create instance classify it, should introduce value attribute class? "?" or "-1" or this. changes anything? example:
arraylist<double> featurevector = new arraylist<double>(); featurevector.add((double) 0); featurevector.add((double) 85); featurevector.add((double) 85); featurevector.add((double) 1); //featurevector.add((double) -1); -> class attribute instances instances = classification.featurevectortoinstances(featurevector); result = classification.classifyinstancetostring(instances.firstinstance());
and functions:
public instances featurevectortoinstances(arraylist featurevector){
instances instances = new instances("instances", attributes, 0); denseinstance instance = new denseinstance(attributes.size()); for(int = 0; < featurevector.size(); i++) instance.setvalue(i, featurevector.get(i)); instances.add(instance); //set class attribute instances.setclassindex(attributes.size()-1); return instances;
}
public string classifyinstancetostring(instance unlabeled) throws exception{
double clslabel = cmodel.classifyinstance(unlabeled); unlabeled.setclassvalue(clslabel); return unlabeled.classattribute().value((int)clslabel);
}
thanks in advance
if understood correctly:
you have provide label train intances. why: learning algorithm builds model using traiing data, using model classifies new instances, , evaluates own class predictions, comparing them original labels. without labels no evaluation of algorithm performance possible.
Comments
Post a Comment