尝试使用MatLab + Weka构建分类器时出错

时间:2013-05-27 13:03:49

标签: matlab classification weka

我正在尝试使用weka + Matlab对某些分类器进行分类,但是,有些分类器不接受我使用setOptions发送的参数。

看看这个测试代码,我不知道为什么,Logistic分类器构建正确,但是Ibk出现错误:

%Load the csv File returning an object with the features.
wekaObj= loadCSV('C:\experimento\selecionados para o experimento\Experimento Final\dados\todos.csv');

%Create an instance of the Logistic classifier - OK
classifier1=javaObject(['weka.classifiers.','functions.Logistic']);
classifier1.setOptions('-R 1.8E-8 -M -1');
classifier1.buildClassifier(wekaObj);

%Create an instance of the K-nearest Neighbour classifier - Error
classifier2=javaObject(['weka.classifiers.','lazy.IBk']);
classifier2.setOptions('-K 10 -W 0 -A "weka.core.neighboursearch.LinearNNSearch -A \"weka.core.EuclideanDistance -R first-last\""');
classifier2.buildClassifier(wekaObj);

%Create an instance of the random forest classifier - Error
classifier3=javaObject(['weka.classifiers.','trees.RandomForest']);
classifier3.setOptions('-I 1200 -K 0 -S 1 -num-slots 1');
classifier3.buildClassifier(wekaObj);

%Create an instance of the MultiLayer Perceptron classifier - Error
classifier4=javaObject(['weka.classifiers.','functions.MultilayerPerceptron']);
classifier4.setOptions('-L 0.1 -M 0.1 -N 500 -V 0 -S 0 -E 20 -H a');
classifier4.buildClassifier(wekaObj);

错误就是那个:

Error using weka.classifiers.lazy.IBk/setOptions
Java exception occurred:
java.lang.Exception: Illegal options: -K 10 -W 0 -A
"weka.core.neighboursearch.LinearNNSearch -A "weka.core.EuclideanDistance -R
first-last""
at weka.core.Utils.checkForRemainingOptions(Utils.java:534)
at weka.classifiers.lazy.IBk.setOptions(IBk.java:715)

这里有没有人遇到同样的问题?

obs:对不起可能的拼写错误,英语是我的第二语言。

1 个答案:

答案 0 :(得分:1)

我能够弄清楚出了什么问题,正确的实施:

%Load the csv File returning an object with the features.
wekaObj= loadCSV('C:\experimento\selecionados para o experimento\Experimento Final\dados\todos.csv');

%Create an instance of the Logistic classifier - OK
classifier1=javaObject(['weka.classifiers.','functions.Logistic']);
classifier1.setOptions('-R 1.8E-8 -M -1');
classifier1.buildClassifier(wekaObj);

%Create an instance of the K-nearest Neighbour classifier - Error
classifier2=javaObject(['weka.classifiers.','lazy.IBk']);
classifier2.setOptions(weka.core.Utils.splitOptions('-K 10 -W 0 -A "weka.core.neighboursearch.LinearNNSearch -A \"weka.core.EuclideanDistance -R first-last\""'));
classifier2.buildClassifier(wekaObj);

%Create an instance of the random forest classifier - Error
classifier3=javaObject(['weka.classifiers.','trees.RandomForest']);
classifier3.setOptions(weka.core.Utils.splitOptions('-I 1200 -K 0 -S 1'));
classifier3.buildClassifier(wekaObj);

%Create an instance of the MultiLayer Perceptron classifier - Error
classifier4=javaObject(['weka.classifiers.','functions.MultilayerPerceptron']);
classifier4.setOptions(weka.core.Utils.splitOptions('-L 0.1 -M 0.1 -N 500 -V 0 -S 0 -E 20 -H a'));
classifier4.buildClassifier(wekaObj);