diff --git a/src/suite.py b/src/suite.py index f892703..3725deb 100644 --- a/src/suite.py +++ b/src/suite.py @@ -360,9 +360,7 @@ class CVSuite: # Normalise data using loaded scalers for idx, value in enumerate(data): d = np.array(value) - data[idx] = self.scaler[idx].transform(d.astype(np.float32).reshape(1, -1))[ - 0 - ][0] + data[idx] = self.scaler[idx].transform(d.astype(np.float32).reshape(1, -1))[0][0] data = np.array([data], dtype=np.float32) @@ -397,13 +395,19 @@ class CVSuite: modelnr = (idx * 2) + idy guesses = self.models[modelnr][2] + for guess in guesses: + print(guess) + # Convert guess array tag_true = [guess[0] for guess in guesses ] tag_predict = [guess[1] for guess in guesses ] labels = [Tree(tag).name for tag in range(0, 8)] - sns.heatmap(confusion_matrix(tag_true, tag_predict), xticklabels=labels, yticklabels=labels, ax=graph, annot=True, cbar=False, fmt='g') + cm = confusion_matrix(tag_true, tag_predict) + cmn = cmn = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] + sns.heatmap(cmn, xticklabels=labels, yticklabels=labels, ax=graph, annot=True, cbar=False, fmt='.2f') + graph.set_title(self.models[modelnr][0]) graph.set_xlabel("Predicted") graph.set_ylabel("Actual") @@ -508,7 +512,7 @@ class CVSuite: img_sobel = img_gray self.canvas.add(img_sobel, "Sobel_edge") - self.log.add("Sobel nonzero", cv2.countNonZero(img_sobel)) + # self.log.add("Sobel nonzero", cv2.countNonZero(img_sobel)) # Canny edge img_canny = cv2.Canny(image=img_blur, threshold1=ct1, threshold2=ct2) @@ -551,8 +555,9 @@ class CVSuite: # Write results to CSV file if not part_update: - self.runTest(self.log.data) - self.drawConfusionMatrix() + if self.models != []: + self.runTest(self.log.data) + self.drawConfusionMatrix() self.log.update() else: