如何在matlab中分割weka分类器的百分比 嗨有以下代码,但我无法得到拆分百分比显示错误
javaaddpath('weka.jar');
import weka.core.Instances.*
import weka.classifiers.functions.supportVector.*
%import weka.core.converters.ConverterUtils$DataSource.*
filename = 'c.arff';
filename1 = 'ctest.arff';
cross='10';
reader = javaObject('java.io.FileReader', filename);
data = javaObject('weka.core.Instances', reader);
if (data.classIndex() == -1) % -1 means that it is undefined
data.setClassIndex(data.numAttributes() - 1);
end
c = weka.classifiers.functions.SMO();
c.setC(100);
k = weka.classifiers.functions.supportVector.Puk();
k.setOmega(1.0);
k.setSigma(1.0);
c.setKernel(k);
c.buildClassifier(data); %% "data" here is the training data
% evaluate model (simple evaluation over training set)
ev = weka.classifiers.Evaluation(data); % "data" here is the test data
v(1) = java.lang.String('-t');
v(2) = java.lang.String(filename);
v(3) = java.lang.String('-T');
v(4) = java.lang.String(filename1);
v(5) = java.lang.String('-split-percentage');
v(6) = java.lang.String('80');
v(7) = java.lang.String('-i');
params = cat(1,v(1:end));
ev.evaluateModel(c, params)
答案 0 :(得分:0)
这是我的问题的答案 用于10倍交叉验证的matlab代码是
javaaddpath('weka.jar');
import weka.core.Instances.*
import weka.classifiers.*
filename = 'c.arff';
reader = javaObject('java.io.FileReader', filename);
data = javaObject('weka.core.Instances', reader);
if (data.classIndex() == -1) % -1 means that it is undefined
data.setClassIndex(data.numAttributes() - 1);
end
c = weka.classifiers.trees.J48();
c.buildClassifier(data);
ev = weka.classifiers.Evaluation(data); % "data" here is the test data
v(1) = java.lang.String('-t');
v(2) = java.lang.String(filename);
v(3) = java.lang.String('-x');
v(4) = java.lang.String('10');
v(5) = java.lang.String('-i');
params = cat(1,v(1:end));
ev.evaluateModel(c, params)
分类器百分比分割的答案
javaaddpath('weka.jar');
import weka.core.Instances.*
import weka.classifiers.*
filename = 'c.arff';
reader = javaObject('java.io.FileReader', filename);
data = javaObject('weka.core.Instances', reader);
if (data.classIndex() == -1) % -1 means that it is undefined
data.setClassIndex(data.numAttributes() - 1);
end
c = weka.classifiers.trees.J48();
c.buildClassifier(data);
ev = weka.classifiers.Evaluation(data); % "data" here is the test data
v(1) = java.lang.String('-t');
v(2) = java.lang.String(filename);
v(3) = java.lang.String('-split-percentage');
v(4) = java.lang.String('80');
v(5) = java.lang.String('-i');
params = cat(1,v(1:end));
ev.evaluateModel(c, params)