0

如何在matlab中进行weka分类器的拆分百分比 hi有以下代码,但我无法获得拆分百分比它显示错误

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)
4

1 回答 1

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)
于 2013-08-23T15:44:57.110 回答