classifier.setOptions(weka.core.Utils.splitOptions())即使在matlab中提供其他值也只采用默认值

时间:2016-12-07 07:11:05

标签: matlab weka

import weka.core.Instances.*

filename = 'C:\Users\Girish\Documents\MATLAB\DRESDEN_NSC.csv';
loader = weka.core.converters.CSVLoader();
loader.setFile(java.io.File(filename));
data = loader.getDataSet();
data.setClassIndex(data.numAttributes()-1);

%% classification
classifier = weka.classifiers.trees.J48();
classifier.setOptions( weka.core.Utils.splitOptions('-C 0.25 -M 2') );
classifier.buildClassifier(data);
classifier.toString()

ev = weka.classifiers.Evaluation(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('66');
prm = cat(1,v(1:4));
ev.evaluateModel(classifier, prm)

Result:
Time taken to build model: 0.04 seconds
Time taken to test model on training split: 0.01 seconds

=== Error on training split ===

Correctly Classified Instances         767               99.2238 %
Incorrectly Classified Instances         6                0.7762 %
Kappa statistic                          0.9882
Mean absolute error                      0.0087
Root mean squared error                  0.0658
Relative absolute error                  1.9717 %
Root relative squared error             14.042  %
Total Number of Instances              773     


=== Detailed Accuracy By Class ===

                 TP Rate  FP Rate  Precision  Recall   F-Measure  MCC      ROC Area  PRC Area  Class
                 0.994    0.009    0.987      0.994    0.990      0.984    0.999     0.999     Nikon
                 1.000    0.000    1.000      1.000    1.000      1.000    1.000     1.000     Sony
                 0.981    0.004    0.990      0.981    0.985      0.980    0.999     0.997     Canon
Weighted Avg.    0.992    0.004    0.992      0.992    0.992      0.988    1.000     0.999     


=== Confusion Matrix ===

   a   b   c   <-- classified as
 306   0   2 |   a = Nikon
   0 258   0 |   b = Sony
   4   0 203 |   c = Canon


=== Error on test split ===

Correctly Classified Instances         358               89.9497 %
Incorrectly Classified Instances        40               10.0503 %
Kappa statistic                          0.8482
Mean absolute error                      0.0656
Root mean squared error                  0.2464
Relative absolute error                 14.8485 %
Root relative squared error             52.2626 %
Total Number of Instances              398     


=== Detailed Accuracy By Class ===

                 TP Rate  FP Rate  Precision  Recall   F-Measure  MCC      ROC Area  PRC Area  Class
                 0.885    0.089    0.842      0.885    0.863      0.787    0.908     0.832     Nikon
                 0.993    0.000    1.000      0.993    0.997      0.995    0.997     0.996     Sony
                 0.796    0.060    0.841      0.796    0.818      0.749    0.897     0.744     Canon
Weighted Avg.    0.899    0.048    0.900      0.899    0.899      0.853    0.938     0.867     


=== Confusion Matrix ===

   a   b   c   <-- classified as
 123   0  16 |   a = Nikon
   0 145   1 |   b = Sony
  23   0  90 |   c = Canon




import weka.core.Instances.*

filename = 'C:\Users\Girish\Documents\MATLAB\DRESDEN_NSC.csv';
loader = weka.core.converters.CSVLoader();
loader.setFile(java.io.File(filename));
data = loader.getDataSet();
data.setClassIndex(data.numAttributes()-1);

%% classification
classifier = weka.classifiers.trees.J48();
classifier.setOptions( weka.core.Utils.splitOptions('-C 0.1 -M 1') );
classifier.buildClassifier(data);
classifier.toString()

ev = weka.classifiers.Evaluation(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('66');

prm = cat(1,v(1:4));
ev.evaluateModel(classifier, prm)

Result:
Time taken to build model: 0.04 seconds
Time taken to test model on training split: 0 seconds

=== Error on training split ===

Correctly Classified Instances         767               99.2238 %
Incorrectly Classified Instances         6                0.7762 %
Kappa statistic                          0.9882
Mean absolute error                      0.0087
Root mean squared error                  0.0658
Relative absolute error                  1.9717 %
Root relative squared error             14.042  %
Total Number of Instances              773     


=== Detailed Accuracy By Class ===

                 TP Rate  FP Rate  Precision  Recall   F-Measure  MCC      ROC Area  PRC Area  Class
                 0.994    0.009    0.987      0.994    0.990      0.984    0.999     0.999     Nikon
                 1.000    0.000    1.000      1.000    1.000      1.000    1.000     1.000     Sony
                 0.981    0.004    0.990      0.981    0.985      0.980    0.999     0.997     Canon
Weighted Avg.    0.992    0.004    0.992      0.992    0.992      0.988    1.000     0.999     


=== Confusion Matrix ===

   a   b   c   <-- classified as
 306   0   2 |   a = Nikon
   0 258   0 |   b = Sony
   4   0 203 |   c = Canon


=== Error on test split ===

Correctly Classified Instances         358               89.9497 %
Incorrectly Classified Instances        40               10.0503 %
Kappa statistic                          0.8482
Mean absolute error                      0.0656
Root mean squared error                  0.2464
Relative absolute error                 14.8485 %
Root relative squared error             52.2626 %
Total Number of Instances              398     


=== Detailed Accuracy By Class ===

                 TP Rate  FP Rate  Precision  Recall   F-Measure  MCC      ROC Area  PRC Area  Class
                 0.885    0.089    0.842      0.885    0.863      0.787    0.908     0.832     Nikon
                 0.993    0.000    1.000      0.993    0.997      0.995    0.997     0.996     Sony
                 0.796    0.060    0.841      0.796    0.818      0.749    0.897     0.744     Canon
Weighted Avg.    0.899    0.048    0.900      0.899    0.899      0.853    0.938     0.867     


=== Confusion Matrix ===

   a   b   c   <-- classified as
 123   0  16 |   a = Nikon
   0 145   1 |   b = Sony
  23   0  90 |   c = Canon

两个拆分选项的结果相同,这是默认选项的结果,即J48分类器的-C 0.25 -M 2

请帮忙!!!在这里坚持了很长时间。不同的意思,但没有任何作用对我来说

0 个答案:

没有答案