-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
48 lines (39 loc) · 815 Bytes
/
data.py
File metadata and controls
48 lines (39 loc) · 815 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#Some helper functions to make the entire thing run
import math
import numpy as np
import scipy
import scipy.cluster.hierarchy as hcluster
from scipy.cluster.vq import vq, kmeans, whiten
def split(arr,k):
pholder,clusters = scipy.cluster.vq.kmeans2(arr,k,minit='points')
print(clusters)
big = []
for i in range(0,len(set(clusters))):
small = []
for j in range(0,len(arr)):
if (clusters[j]==i+1):
small.append(arr[j,:])
big.append(small)
#print(big)
return big
def submat(mat,subset):
q = len(subset)
print(q)
ret = np.zeros(q*q)
ret = np.reshape(ret,(q,q))
w = 0
for i in subset:
z = 0
for j in subset:
ret[w,z] = mat[i,j]
z=z+1
w=w+1
return ret
def submean(mean,subset):
q = len(subset)
m = np.zeros(q)
w = 0
for i in subset:
m[w] = mean[i]
w=w+1
return m