Browse Source

Another model update

tags/SensorLogger/0.2.3
Chris Smith 14 years ago
parent
commit
5eb68f5b83

BIN
code/Extractor/dist/Extractor.jar View File


BIN
code/Extractor/dist/basic.model View File


+ 4
- 3
code/Extractor/src/uk/co/md87/dsp/extractor/Classifier.java View File

@@ -42,11 +42,11 @@ public class Classifier {
42 42
         }
43 43
     }
44 44
 
45
-    public String classify(final Window window) {
45
+    public String[] classify(final Window window) {
46 46
         final Float[] target = window.getFeatures(features).values().toArray(
47 47
                 new Float[features.size()]);
48 48
         float best = Float.MAX_VALUE;
49
-        String bestActivity = "UNCLASSIFIED/UNKNOWN";
49
+        String bestActivity = "UNCLASSIFIED/UNKNOWN", secondBest = bestActivity;
50 50
 
51 51
         for (Map.Entry<Float[], String> entry : model.entrySet()) {
52 52
             float distance = 0;
@@ -57,11 +57,12 @@ public class Classifier {
57 57
 
58 58
             if (distance < best) {
59 59
                 best = distance;
60
+                secondBest = bestActivity;
60 61
                 bestActivity = entry.getValue();
61 62
             }
62 63
         }
63 64
 
64
-        return bestActivity;
65
+        return new String[]{bestActivity,secondBest};
65 66
     }
66 67
 
67 68
 }

+ 6
- 3
code/Extractor/src/uk/co/md87/dsp/extractor/test/TrainingDataClassifier.java View File

@@ -79,15 +79,18 @@ public class TrainingDataClassifier {
79 79
 
80 80
                 for (Window window : new Windower(dataset).getWindows()) {
81 81
                     if (j++ % 3 != 0) {
82
-                        continue;
82
+                        //continue;
83 83
                     }
84 84
 
85
-                    String bestActivity = c.classify(window);
85
+                    String[] bestActivities = c.classify(window);
86
+                    String bestActivity = bestActivities[0];
86 87
 
87 88
                     if (bestActivity.equals(activity)) {
88 89
                         right++;
89 90
                     } else {
90
-                        System.out.println("Wrong: " + activity + " classified as " + bestActivity);
91
+                        System.out.println("Wrong: " + activity
92
+                                + " classified as " + bestActivity
93
+                                + "; 2nd best: " + bestActivities[1]);
91 94
                         wrong++;
92 95
                     }
93 96
                 }

BIN
code/SensorLogger/res/raw/basic_model View File


Loading…
Cancel
Save