aboutsummaryrefslogtreecommitdiff
path: root/evaluate.py
diff options
context:
space:
mode:
Diffstat (limited to 'evaluate.py')
-rwxr-xr-xevaluate.py15
1 files changed, 2 insertions, 13 deletions
diff --git a/evaluate.py b/evaluate.py
index 6b8fc80..b4d4a33 100755
--- a/evaluate.py
+++ b/evaluate.py
@@ -14,24 +14,13 @@ from sklearn.cluster import KMeans
data = np.load(DATA_FILE)
train = data['desc_tr']
+train_part = data['desc_sel'].T
-# Train part will contain 15 000 descriptors to generate KMeans
-part_idx = np.random.randint(train.shape[1])
-
-parts = []
-for i in train[:, part_idx]:
- parts.append(i.T[300:1300])
-
-train_part = np.vstack(parts)
-
-print(train_part.shape)
-
+print("Computing KMeans with", train_part.shape[0], "keywords")
kmeans = KMeans(n_clusters=CLUSTER_CNT, random_state=0).fit(train_part)
print("Generating histograms")
-
histogram = np.zeros((train.shape[0], train.shape[1],CLUSTER_CNT))
-
for i in range(train.shape[0]):
for j in range(train.shape[1]):
histogram[i][j] = np.bincount(kmeans.predict(train[i][j].T),minlength=CLUSTER_CNT)