我想用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