From 156e4a9961ed44d68535d9e932e61b0933087504 Mon Sep 17 00:00:00 2001 From: Tom Selier Date: Fri, 20 Oct 2023 17:22:31 +0200 Subject: [PATCH] .2 procent --- src/experiments/knn/knn.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/experiments/knn/knn.py b/src/experiments/knn/knn.py index b9a0b36..d20a4e7 100644 --- a/src/experiments/knn/knn.py +++ b/src/experiments/knn/knn.py @@ -3,7 +3,7 @@ import numpy as np import matplotlib.pyplot as plt import seaborn as sns import csv -from sklearn.preprocessing import MinMaxScaler +from sklearn.preprocessing import MinMaxScaler, StandardScaler, RobustScaler, MaxAbsScaler from enum import Enum import random from sklearn.metrics import confusion_matrix, accuracy_score, precision_score, recall_score, matthews_corrcoef @@ -19,7 +19,7 @@ class Tree(Enum): PLATAAN = 7 # Open file -file = open('./out/result-2023-10-10T15.08.36.csv', "r") +file = open('dataset\\csv\\result-2023-10-14T16.13.30.csv', "r") data = list(csv.reader(file, delimiter=",")) file.close() @@ -32,6 +32,7 @@ tags_int = [] for row in data: tree = row.pop(0) + row.pop(1) # TODO: Doe dit niet id = Tree[tree.upper()] # print("Tree name =", tree, " id =", id.value) @@ -52,14 +53,16 @@ for idx, col in enumerate(data[0]): column = np.array(column).reshape(-1, 1) # Perform Min - Max scaling - scaler = MinMaxScaler() + # scaler = MinMaxScaler() + scaler = MaxAbsScaler() + column = scaler.fit_transform(column) # Reshape it back cus scaler is dumb af column = np.array(column).reshape(len(column)) # DEBUG Print resulting column - # print("NORM", header[idx + 1], "\n", column) + print("NORM", header[idx + 1], "\n", column) # Replace original data array data[:, idx] = column