Skip to content

Commit 7b34a33

Browse files
author
Maria Littmann
committed
Bugs fixed
1 parent 22df8db commit 7b34a33

File tree

4 files changed

+67
-62
lines changed

4 files changed

+67
-62
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.idea/workspace.xml

Lines changed: 49 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

embedding_lookup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ def run_embedding_lookup_distance(self, querys, metric):
3939
else:
4040
sys.exit("{} is not a correct distance metric\n"
4141
"See <sklearn.metrics.pairwise.distance_metrics()> "
42-
"for all possible distance metrics".format(distance))
42+
"for all possible distance metrics".format(metric))
4343

4444
return distances, query_ids

function_prediction.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def run_prediction_embedding_all(self, querys, distance, hits, criterion):
5353

5454
for i in range(0, len(query_ids)):
5555
query = query_ids[i].split()[0]
56-
dists = distances[i, :].squeeze().numpy()
56+
dists = distances[i, :].squeeze()
5757
for h in hits:
5858
prediction = dict()
5959
if criterion == 'dist': # extract hits within a certain distance
@@ -198,3 +198,19 @@ def run_prediction_one_target(self, query_embedding, distance, k, criterion):
198198
del prediction[k]
199199

200200
return prediction
201+
202+
@staticmethod
203+
def write_predictions(predictions, out_file):
204+
"""
205+
Write prediictions
206+
:param predictions: predictions to write
207+
:param out_file: output file
208+
:return:
209+
"""
210+
with open(out_file, 'w') as out:
211+
for p in predictions.keys():
212+
prediction = predictions[p]
213+
for pred in prediction.keys():
214+
ri = prediction[pred]
215+
out.write('{}\t{}\t'.format(p, pred))
216+
out.write('{:0.2f}\n'.format(float(ri)))

0 commit comments

Comments
 (0)