1

简单快速的怀疑。假设我的 ARFF 看起来像这样:

@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 个属性(4 个没有类属性)。当我创建一个Instance进行分类时,我应该为属性类引入一个值吗?喜欢 ”?” 或“-1”或类似的东西。它会改变什么吗?例子:

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());

和功能:

公共实例 featureVectorToInstances(ArrayList featureVector){

Instances instances = new Instances("Instances", attributes, 0);    
DenseInstance instance = new DenseInstance(attributes.size());

for(int i = 0; i < featureVector.size(); i++)

    instance.setValue(i, featureVector.get(i));

instances.add(instance);    
//Set class attribute
instances.setClassIndex(attributes.size()-1);

return instances;

}

公共字符串分类InstanceToString(实例未标记)抛出异常{

double clsLabel = cModel.classifyInstance(unlabeled);
unlabeled.setClassValue(clsLabel);
return unlabeled.classAttribute().value((int)clsLabel);

}

提前致谢

4

1 回答 1

0

如果我理解正确:

您必须为火车实例提供标签。原因:学习算法使用跟踪数据构建模型,然后使用模型对新实例进行分类,然后评估他自己的类预测,将它们与原始标签进行比较。因此,如果没有标签,就无法评估算法性能。

于 2013-08-08T15:07:22.623 回答