-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcluster.py
More file actions
29 lines (24 loc) · 751 Bytes
/
Copy pathcluster.py
File metadata and controls
29 lines (24 loc) · 751 Bytes
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
import numpy as np
from sklearn.cluster import KMeans,FeatureAgglomeration
import pickle
import matplotlib.pyplot as plt
from sklearn.decomposition import IncrementalPCA
#from scipy.cluster.vq import kmeans,vq,whiten
from sklearn import metrics
np.random.seed(42)
with open('extracted_features.pickle','rb') as f:
data=pickle.load(f)
with open('extracted_features2.pickle','rb') as f:
data2=pickle.load(f)
labels1=np.array([0 for i in range(70)])
labels2=np.array([1 for i in range(60)])
labels=np.concatenate((labels1,labels2),axis=0)
#print(labels)
print(data.shape)
print(data2.shape)
x=np.concatenate((data,data2))
print(x.shape)
kmeans = KMeans(n_clusters=2)
clx=kmeans.fit_predict(x)
print(clx)
print(metrics.accuracy_score(labels,clx))