From b140cb09dd8d10d11cbbda46e81231bb1fc4d179 Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Mon, 4 Feb 2019 17:36:00 +0000 Subject: Use desc_sel for KMeans generation --- evaluate.py | 15 ++------------- 1 file 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) -- cgit v1.2.3-54-g00ecf