Commit 6a302257 authored by 赵威's avatar 赵威

get res by distances

parent 656388d7
...@@ -32,7 +32,11 @@ def match_tractate_by_device(device_id, n=10): ...@@ -32,7 +32,11 @@ def match_tractate_by_device(device_id, n=10):
vectors.append(np.array(lst).astype("float32")) vectors.append(np.array(lst).astype("float32"))
if vectors: if vectors:
D, I = FAISS_TAGS_INDEX.search(np.array([np.average(vectors, axis=0)]).astype("float32"), n) D, I = FAISS_TAGS_INDEX.search(np.array([np.average(vectors, axis=0)]).astype("float32"), n)
res = I.tolist()[0] distances = D.tolist()[0]
ids = I.tolist()[0]
for (index, i) in enumerate(distances):
if i <= 5.0:
res.append(ids[index])
time_end = time.time() - time_begin time_end = time.time() - time_begin
if time_end > 0.04: if time_end > 0.04:
send_performance_msg_to_dingtalk("match_tractate_by_device {} n={} cost {:.3f}ms".format( send_performance_msg_to_dingtalk("match_tractate_by_device {} n={} cost {:.3f}ms".format(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment