Exemple #1
0
print 'Clustering 3 classes : \n'

#nombre de clusters
nb_cluster = 3

#N.B : difference qu'on souhaite evaluer sur les phonemes : separation consonnes/voyelles = 0, voisee/non-voisee = 1, categories = 2

#KMEANS non initialise 3 classes
clus = MiniBatchKMeans(n_clusters = nb_cluster, init='k-means++',  batch_size=700,
                                  n_init=10, max_no_improvement=10, verbose=0)
f = open(fichier, "a")
f.write("KMEANS non initialise 3 clusters\n")
f.close()
clus.fit(X)
labels = clus.labels_
pourcentage(Y , nb_cluster, labels , dict_path , 0, fichier)
pourcentage(Y , nb_cluster, labels , dict_path , 1, fichier)
pourcentage(Y , nb_cluster, labels , dict_path , 2, fichier)

#KMEANS initialise 3 classes
sous = initialisation_centres(nb_cluster, X)
clus = MiniBatchKMeans(n_clusters = nb_cluster, init=sous,  batch_size=700,
                                  n_init=10, max_no_improvement=10, verbose=0)
f = open(fichier, "a")
f.write("KMEANS initialise 3 clusters\n")
f.close()
clus.fit(X)
labels = clus.labels_
pourcentage(Y , nb_cluster, labels , dict_path , 0, fichier)
pourcentage(Y , nb_cluster, labels , dict_path , 1, fichier)
pourcentage(Y , nb_cluster, labels , dict_path , 2, fichier)
print "Clustering miniBatch K-means non supervise : \n"
# nombre de clusters
nb_cluster = 3

# N.B : difference qu'on souhaite evaluer sur les phonemes : separation consonnes/voyelles = 0, voisee/non-voisee = 1, categories = 2

# KMEANS non initialise 3 classes
clus = MiniBatchKMeans(
    n_clusters=nb_cluster, init="k-means++", batch_size=700, n_init=10, max_no_improvement=10, verbose=0
)
f = open(fichier, "a")
f.write("KMEANS non initialise 3 clusters\n")
f.close()
clus.fit(X)
labels = clus.labels_
pourcentage(Y, nb_cluster, labels, path_dict, 0, fichier)
pourcentage(Y, nb_cluster, labels, path_dict, 1, fichier)

# KMEANS initialise 3 classes
print "Clustering miniBatch k-means supervise : \n"
sous = initialisation_centres(nb_cluster, X)
clus = MiniBatchKMeans(n_clusters=nb_cluster, init=sous, batch_size=700, n_init=10, max_no_improvement=10, verbose=0)
f = open(fichier, "a")
f.write("KMEANS initialise 3 clusters\n")
f.close()
clus.fit(X)
labels = clus.labels_
pourcentage(Y, nb_cluster, labels, path_dict, 0, fichier)
pourcentage(Y, nb_cluster, labels, path_dict, 1, fichier)

# Agglomerative clustering 3 classes
Exemple #3
0
#N.B : difference qu'on souhaite evaluer sur les phonemes : separation consonnes/voyelles = 0, voisee/non-voisee = 1, categories = 2

#KMEANS non initialise 3 classes
clus = MiniBatchKMeans(n_clusters=nb_cluster,
                       init='k-means++',
                       batch_size=700,
                       n_init=10,
                       max_no_improvement=10,
                       verbose=0)
f = open(fichier, "a")
f.write("KMEANS non initialise 3 clusters\n")
f.close()
clus.fit(X)
labels = clus.labels_
pourcentage(Y, nb_cluster, labels, path_dict, 0, fichier)
pourcentage(Y, nb_cluster, labels, path_dict, 1, fichier)

#KMEANS initialise 3 classes
print 'Clustering miniBatch k-means supervise : \n'
sous = initialisation_centres(nb_cluster, X)
clus = MiniBatchKMeans(n_clusters=nb_cluster,
                       init=sous,
                       batch_size=700,
                       n_init=10,
                       max_no_improvement=10,
                       verbose=0)
f = open(fichier, "a")
f.write("KMEANS initialise 3 clusters\n")
f.close()
clus.fit(X)
Exemple #4
0
# Read mat file and align file.
filename = '../data/Bref80_L4M01.mat'
alignfile = '../data/Bref80_L4M01.aligned'
fbank = sio.loadmat(filename)['d1']
csv = "../resultats/resultatsClustering/matlabFbank.csv"
classementPath = "../data/classement"
hop_span = 0.01
Y = utiles.getY(fbank, alignfile, hop_span)

#Kmeans without initialization 3 classes (consonnes et voyelles)
n_clusters = 3
kmeans = KMeans(init='k-means++', n_clusters=n_clusters, n_init=10)
kmeans.fit(fbank)
centroids = kmeans.cluster_centers_
labels = kmeans.labels_
analyse.pourcentage(Y, n_clusters, labels, classementPath, 0, csv)

#Kmeans without initialization 3 classes
n_clusters = 3
kmeans = KMeans(init='k-means++', n_clusters=n_clusters, n_init=10)
kmeans.fit(fbank)
centroids = kmeans.cluster_centers_
labels = kmeans.labels_
analyse.pourcentage(Y, n_clusters, labels, classementPath, 1, csv)

#Kmeans withous initialzation 6 classes

n_clusters = 6
kmeans = KMeans(init='k-means++', n_clusters=n_clusters, n_init=10)
kmeans.fit(fbank)
centroids = kmeans.cluster_centers_
# Read mat file and align file.
filename = '../data/Bref80_L4M01.mat'
alignfile = '../data/Bref80_L4M01.aligned'
fbank = sio.loadmat(filename)['d1']
csv = "../resultats/resultatsClustering/matlabFbank.csv"
classementPath = "../data/classement"
hop_span = 0.01
Y = utiles.getY(fbank,alignfile,hop_span)

#Kmeans without initialization 3 classes (consonnes et voyelles)
n_clusters = 3
kmeans = KMeans(init='k-means++', n_clusters=n_clusters, n_init=10)
kmeans.fit(fbank)
centroids = kmeans.cluster_centers_
labels = kmeans.labels_
analyse.pourcentage(Y,n_clusters,labels,classementPath,0,csv)

#Kmeans without initialization 3 classes
n_clusters = 3
kmeans = KMeans(init='k-means++', n_clusters=n_clusters, n_init=10)
kmeans.fit(fbank)
centroids = kmeans.cluster_centers_
labels = kmeans.labels_
analyse.pourcentage(Y,n_clusters,labels,classementPath,1,csv)

#Kmeans withous initialzation 6 classes

n_clusters = 6
kmeans = KMeans(init='k-means++', n_clusters=n_clusters, n_init=10)
kmeans.fit(fbank)
centroids = kmeans.cluster_centers_