Easy Support Vector Machine

Dependents:   WeatherPredictor

Revision:
1:1a0d5152d50b
Parent:
0:3f38e74a4a77
Child:
2:c4a5251cee32
--- a/MCSVM.cpp	Thu Jan 15 08:22:02 2015 +0000
+++ b/MCSVM.cpp	Wed Jan 28 15:22:10 2015 +0000
@@ -140,7 +140,7 @@
   float prob;
   float* result_label_prob = new float[n_class];
   int tmp_ci, tmp_cj;
-  memset(result_label_count, 0, sizeof(int) * n_class);
+  memset(result_label_prob, 0, sizeof(float) * n_class);
   for (int ci = 0; ci < n_class; ci++) {
     for (int cj = ci + 1; cj < n_class; cj++) {
 
@@ -156,9 +156,9 @@
       // 確率識別:確率の足し上げ
       prob = SVM::predict_probability(data);
       if ( prob > float(0.5) ) {
-          result_label_count[cj] += prob;
+          result_label_prob[cj] += prob;
       } else {
-          result_label_count[ci] += (1-prob);
+          result_label_prob[ci] += (1-prob);
       }
 
     }
@@ -177,7 +177,7 @@
 
   delete [] result_label_prob;
   // 平均確率を返す.
-  return (max / n_class);
+  return (max / (n_class-1));
 
 }
 
@@ -196,6 +196,6 @@
         return;
     }
     int nC2 = n_class * (n_class - 1)/2;
-    memcpy(mc_alpha, mcalpha_data, sizeof(float) * nsample * (n_class * (n_class - 1) / 2));
+    memcpy(mc_alpha, mcalpha_data, sizeof(float) * n_sample * (n_class * (n_class - 1) / 2));
     status = SVM_SET_ALPHA;
 }