繁体   English   中英

如何使用经过训练的随机森林 model 对没有标签的 ARFF 文件进行分类?

[英]How to classify ARFF file with no labels using a trained Random Forest model?

我有一个训练和测试 ARFF 文件数据集。 我通过从 6 波段图像和与每个坐标相关的标签中提取感兴趣区域来创建以下数据集。

@RELATION agricultural.data

@attribute band0 numeric
@attribute band1 numeric
@attribute band3 numeric
@attribute band4 numeric
@attribute band5 numeric
@attribute band6 numeric
@attribute class {1,2,3,4,5,6,7,8,9}

@data
-10.95659,-7.61896,-9.8674499,-9.118701,-8.620638,-12.699167,5
...
-9.172866,-9.814803,-10.693634,-13.313326,-8.568673,-12.355089,3

使用上述数据,我训练了 RandomForest 并获得了一些看起来符合我预期的结果。


我有一个 ARFF 文件数据集。 它没有任何 class 属性

@RELATION agricultural.data.fullimage

@attribute band0 numeric
@attribute band1 numeric
@attribute band3 numeric
@attribute band4 numeric
@attribute band5 numeric
@attribute band6 numeric

@data
-9.261405,-7.302625,-10.753542,-8.018068,-7.776727,-12.878252
...
-9.188496,-10.676176,-14.194083,-9.687324,-9.785445,-12.490084

这是逐行生成的实际图像 ARFF 文件。 我想对整个图像进行分类。 它没有任何标签。 我如何对图像进行分类。 (分割?)

FilteredClassifier fc = new FilteredClassifier();
fc.setClassifier(myRandomForestTrainedModel);

for(int pixel=0;pixel < ncols;pixel++) {
    double prediction;
    /**Some edge case handling**/
    prediction = fc.classifyInstance(data.instance(pixel)); //Each data here is a row in the image which I create an ARFF file for
    byteLinePrediction[pixel] = (byte)Math.floor(prediction+0.5);
} 

classifyInstance() function 有一个异常,如下所示:

weka.core.UnassignedClassException: weka.classifiers.meta.FilteredClassifier: Class attribute not set!

但是,我没有为这些像素分配类,因为我不想评估分类器的性能,而是使用分类器生成分类(分割)图像 map。

您用于进行预测的数据需要与训练数据具有完全相同的格式,包括 class 属性(Weka 可能会在预测时查询可能的 class 值)。 该属性还必须标记为 class 属性 ( setClassIndex(...) )。

但是,数据部分中的所有实际值都可能丢失('?')。

您可以使用Add filter to append 将 class 属性添加到您的测试数据,包括所需的标称标签。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM