我想用Weka打印J48分类器的混淆矩阵。我得到的输出是每个映射器的矩阵数。运行的映射器数量设置为两个。为了得到从减速器只有一个汇总值
这个类是Weka分类器输出的缩减器它给出了来自映射器的一串交叉验证的数据块,它的工作是将数据聚合成一个解决方案。
public void reduce(Text key, Iterable<AggregateableEvaluation> values, Context context) throws IOException, InterruptedException {
int sum = 0;
// loop through each of the values and "aggregate"
// which basically means to consolidate the values
for (AggregateableEvaluation val : values) {
System.out.println("IN THE REDUCER!");
// The first time through, give aggEval a value
if (sum == 0) {
try {
aggEval = val;
}
catch (Exception e) {
e.printStackTrace();
}
}
else {
// combine the values
aggEval.aggregate(val);
}
try {
// This is what is taken from the mapper to be aggregated
//System.out.println("This is the map result");
//System.out.println(aggEval.toMatrixString());
}
catch (Exception e) {
e.printStackTrace();
}
sum += 1;
}
try {
System.out.println("This is reduce matrix");
System.out.println(aggEval.toMatrixString());
}
catch (Exception e) {
e.printStackTrace();
}
不要得到它。什么是问题? – Zelldon
@Zelldon我想打印一个混淆矩阵,即weka输出,但我得到很多矩阵......我不确定,但它的像reducer正在执行许多次。 – Amogh