Weka混淆矩阵

时间:2015-01-15 04:06:09

标签: machine-learning weka data-mining confusion-matrix

我有以下数据集 weather.nominal.arff

@relation weather.symbolic

@attribute outlook {sunny, overcast, rainy}
@attribute temperature {hot, mild, cool}
@attribute humidity {high, normal}
@attribute windy {TRUE, FALSE}
@attribute play {yes, no}

@data
sunny,hot,high,FALSE,no
sunny,hot,high,TRUE,no
overcast,hot,high,FALSE,yes
rainy,mild,high,FALSE,yes
rainy,cool,normal,FALSE,yes 
rainy,cool,normal,TRUE,no  
overcast,cool,normal,TRUE,yes
sunny,mild,high,FALSE,no
sunny,cool,normal,FALSE,yes 
rainy,mild,normal,FALSE,yes
sunny,mild,normal,TRUE,yes
overcast,mild,high,TRUE,yes
overcast,hot,normal,FALSE,yes
rainy,mild,high,TRUE,no

我写了一个简单的程序如下。

   if (data.classIndex() == -1)
        data.setClassIndex(4);

    J48 classifier = new J48();
    Evaluation eval = new Evaluation(data);
    eval.crossValidateModel(classifier, data, 10, new Random(1));

    System.out.println(eval.toMatrixString());

我得到了以下结果。

=== Confusion Matrix ===

 a b   <-- classified as
 0 5 | a = no
 0 9 | b = yes

现在,当我在Weka GUI中使用相同的weather.nominal数据集时,我得到以下结果。

=== Confusion Matrix ===

 a b   <-- classified as
 9 0 | a = yes
 5 0 | b = no

我需要在程序中进行哪些更改才能获得Weka GUI生成的结果?在得到的混淆矩阵中交叉值。

更新 我提到了arff文件,但是我从数据库中获取了相同的值,因为我在数据库中存储了相同的值。该问题仅在我使用数据库时出现,而不是在我使用普通的arff文件时出现。

从数据库加载值的代码。

        InstanceQuery query = new InstanceQuery();
        query.setUsername("postgres");
        query.setPassword("*****");
        query.setQuery("SELECT * from weather");

        Instances data = query.retrieveInstances();

Image of the database table

0 个答案:

没有答案
相关问题