-
Notifications
You must be signed in to change notification settings - Fork 2
/
EM_Algo.py
42 lines (35 loc) · 1.02 KB
/
EM_Algo.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
from sklearn import mixture
import sklearn.datasets
import matplotlib.pyplot as plt
import numpy as np
import generator as g;
from sklearn import preprocessing
def em(input_array,no_of_clusters):
model = sklearn.mixture.GaussianMixture(n_components=no_of_clusters,covariance_type='diag')
a = model.fit(X)
print a.means_
print a.weights_
em = model.predict(X)
l1=em[:59];
l1.sort();
print l1;
l = [len(list(group)) for key, group in groupby(l1)]
print l;
l1=em[59:130];
l1.sort();
print l1;
l = [len(list(group)) for key, group in groupby(l1)]
print l;
l1=em[130:178];
l1.sort();
print l1;
l = [len(list(group)) for key, group in groupby(l1)]
print l;
try:
input_data = np.genfromtxt("C:\\Users\\SUMANTH C\\Desktop\\Deep Learning\\Datasets\\wine_sort.csv",delimiter=',');
except:
print("Could not open file");
input_data = input_data[:,:13];
print input_data.shape;
em(input_data,3);
print("Completed");