From 998011d64694da562a33e02092df1a7b57e84b98 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 22 Sep 2019 00:49:38 +0300 Subject: Preparing for merging two WMD scripts * Added align() to return p_at_one, percentage for both metrics --- WMD_retrieval.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'WMD_retrieval.py') diff --git a/WMD_retrieval.py b/WMD_retrieval.py index fbf1b57..f32372f 100644 --- a/WMD_retrieval.py +++ b/WMD_retrieval.py @@ -93,9 +93,10 @@ def main(args): clf = Wasserstein_Retriever(W_embed=W_common, n_neighbors=5, n_jobs=14, sinkhorn=(metric == 'snk')) clf.fit(X_train_idf[:instances], np.ones(instances)) - dist, preds = clf.kneighbors(X_test_idf[:instances], n_neighbors=instances) - mrr, p_at_one = mrr_precision_at_k(list(range(len(preds))), preds) - percentage = p_at_one * 100 + # dist, preds = clf.kneighbors(X_test_idf[:instances], n_neighbors=instances) + # mrr, p_at_one = mrr_precision_at_k(list(range(len(preds))), preds) + # percentage = p_at_one * 100 + p_at_one, percentage = clf.align(X_test_idf[:instances], n_neighbors=instances) if (not batch): print(f'P @ 1: {p_at_one}\ninstances: {instances}\n{percentage}%') -- cgit v1.2.3-70-g09d2