@@ -111,7 +111,7 @@ private void getClassificationClasses() {
111111 }
112112 }
113113
114- // --- Function for sorting the test data which are going to be classified
114+ // --- Function for sorting the test data which is going to be classified
115115 private void sortClassificationData () {
116116 ArrayList <ArrayList <ArrayList <Float >>> tempSortedClassificationData = new ArrayList <>();
117117 int [] tempNumberDataPerClass = new int [this .rowCount -1 ];
@@ -199,42 +199,47 @@ private void testClassificationModel() {
199199 this .predictedTestData = new String [this .testDataColumnCount ][this .numberOfClasses ][2 ];
200200 this .sortedProbability = new int [this .testDataColumnCount ][this .numberOfClasses ];
201201
202- // Check the distance for every class
203-
202+ // Check the distance for every column of the test dataset
204203 for (int i = 0 ; i < this .testDataColumnCount ; i ++) {
204+ // Create a temporary function for calculating a temporary delta
205205 float [][] tempDelta = new float [this .numberOfClasses ][this .rowCount ];
206+
207+ // Calculating the temporary delta of each row per class
206208 for (int j = 0 ; j < this .numberOfClasses ; j ++) {
209+ // Calculating the current delta value per class
207210 for (int k = 0 ; k < this .rowCount -1 ; k ++) {
208211 tempDelta [j ][k ] = this .featureMean [j ][k ] - this .testDataPredictors [i ][k ];
209212 }
210213
214+ // Getting the prediction per class
211215 this .predictedTestData [i ][j ][0 ] = this .classes [j ];
216+ // Setting temp variables
212217 float tempCalcDistance = 0 ;
213218
219+ // Calculating the distance between data points (pythagorean theorem)
214220 for (int k = 0 ; k < this .rowCount -1 ; k ++) {
215221 tempCalcDistance += (float ) Math .pow (tempDelta [j ][k ], 2 );
216222 }
217-
218223 tempDelta [j ][this .rowCount -1 ] = (float ) Math .sqrt (tempCalcDistance );
219- this .predictedTestData [i ][j ][1 ] = Float .toString (tempDelta [j ][this .rowCount -1 ]);
220-
221- //System.out.print(" " + this.predictedTestData[i][j][0] + " ");
222- //System.out.println(this.predictedTestData[i][j][1]);
223-
224-
225224
225+ // Setting the calculated temp delta to the likeliness of a result
226+ this .predictedTestData [i ][j ][1 ] = Float .toString (tempDelta [j ][this .rowCount -1 ]);
226227 }
228+
227229 float min = Float .valueOf (this .predictedTestData [i ][0 ][1 ]);
228230
229231 int tempIndex = 0 ;
230232 this .sortedProbability [i ][0 ] = tempIndex ;
231233
234+ // Calculating the index of the class with the most likely outcome (best prediction)
232235 for (int j = 0 ; j < this .numberOfClasses ; j ++) {
233236 if (min > Float .valueOf (this .predictedTestData [i ][j ][1 ])) {
234237 min = Float .valueOf (this .predictedTestData [i ][j ][1 ]);
235238 tempIndex = j ;
236239 }
237240 }
241+
242+ // Blackbox for sorting the likeliness for every class
238243 this .sortedProbability [i ][0 ] = tempIndex ;
239244 for (int j = 1 ; j < this .numberOfClasses ; j ++) {
240245 tempIndex = 0 ;
0 commit comments