@@ -9,7 +9,7 @@ public class DATA_evaluation {
9
9
private String [] testDataResults ;
10
10
private int [][] confustionMatrix ;
11
11
12
- private boolean createConfusionMatrix ;
12
+ private boolean createConfusionMatrix = false ;
13
13
14
14
protected DATA_evaluation (String [] testDataResults , int columnCount , String [][][] predictedTestData , int [][] sortedProbability , int numberOfClasses ) {
15
15
this .testDataResults = testDataResults ;
@@ -18,6 +18,7 @@ protected DATA_evaluation(String[] testDataResults, int columnCount, String[][][
18
18
this .sortedProbability = sortedProbability ;
19
19
this .numberOfClasses = numberOfClasses ;
20
20
this .confustionMatrix = new int [this .numberOfClasses ][this .numberOfClasses ];
21
+ this .createConfusionMatrix = false ;
21
22
}
22
23
23
24
private void confusionMatrix () {
@@ -60,15 +61,40 @@ private void confusionMatrix() {
60
61
61
62
}
62
63
63
- protected int [][] getConfusionMatrix () {
64
- if (!createConfusionMatrix ) {
64
+ protected int [][] getConfusionMatrixSimple () {
65
+ if (!this . createConfusionMatrix ) {
65
66
confusionMatrix ();
66
67
}
67
68
68
- return this .confustionMatrix ;
69
+ int [][] confusionMatrixSimple = new int [this .numberOfClasses ][2 ];
70
+ for (int i = 0 ; i < this .numberOfClasses ; i ++) {
71
+ for (int j = 0 ; j < 2 ; j ++) {
72
+ confusionMatrixSimple [i ][j ] = 0 ;
73
+ }
74
+ }
75
+
76
+ for (int i = 0 ; i < this .columnCount ; i ++) {
77
+ if (this .testDataResults [i ].equals (this .predictedTestData [i ][this .sortedProbability [i ][0 ]][0 ])) {
78
+ confusionMatrixSimple [this .sortedProbability [i ][0 ]][0 ]++;
79
+ }
80
+ else {
81
+ confusionMatrixSimple [this .sortedProbability [i ][0 ]][1 ]++;
82
+ }
83
+ }
84
+
85
+
86
+
87
+ for (int i = 0 ; i < 3 ; i ++) {
88
+ for (int j = 0 ; j < 2 ; j ++) {
89
+ System .out .print (confusionMatrixSimple [i ][j ] + " " );
90
+ }
91
+ System .out .println ();
92
+ }
93
+
94
+ return confusionMatrixSimple ;
69
95
}
70
96
protected float [][] getConfusionMatrixNormalized () {
71
- if (!createConfusionMatrix ) {
97
+ if (!this . createConfusionMatrix ) {
72
98
confusionMatrix ();
73
99
}
74
100
float [][] confusionMatrixNormalized = new float [this .numberOfClasses ][this .numberOfClasses ];
@@ -89,14 +115,14 @@ protected float[][] getConfusionMatrixNormalized() {
89
115
}
90
116
91
117
}
92
-
118
+ /*
93
119
for (int i = 0; i < this.numberOfClasses; i++) {
94
120
for (int j = 0; j < this.numberOfClasses; j++) {
95
121
System.out.print(confusionMatrixNormalized[i][j] + " ");
96
122
}
97
123
System.out.println();
98
124
}
99
-
125
+ */
100
126
101
127
return confusionMatrixNormalized ;
102
128
}
0 commit comments