-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_kMean.py
43 lines (28 loc) · 1.42 KB
/
main_kMean.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from norm import *
from kMean import *
import pandas as pd
#------------------------------- IMPORT CSV + MODIFICHE DATASET -------------------------------#
#Importiamo il csv e lo trasformiamo in una matrice
data = pd.read_csv("candy_1.csv", sep = ",", header=None)
data = data.as_matrix()
#Creiamo la matrice x
X = data[:, 0:data.shape[1]-1]
#------------------------------------ NORMALIZAZZIONE FEATURE ---------------------------------#
#------------------------------------- ZSCORE -----------------------------------#
mu, sigma = muSigma(X)
X = zScore(X, mu, sigma)
#--------------------------------------------------------------------------------#
#------------------------------------ MINMAX ------------------------------------#
# min, diff, max = minmax(X)
# X = Min_Max(X, min, diff)
#--------------------------------------------------------------------------------#
#-------------------------------- FEATURE SCALING -------------------------------#
# min, diff, max = minmax(X)
# X = Feat_Scaling(X, max)
#--------------------------------------------------------------------------------#
# clust=[]
# k_mean(X)
#--------------------------------------------------------------------------------#
k,costi,centroidi = best_k(X, 0.3, 100)
print("\n\nk scelto:",k,"\ncosto:",costi,"\ncentroidi:\n",centroidi)
#--------------------------------------------------------------------------------#