I have a csv with columns like: userid, reference, step. I have imported them in python as 3 lists like:
userid = data['user_id']
references = data['reference']
newstep =data['newstep']
for every reference value, which is inside this csv, I return the first 20 similarity values from a neo4j database. I want to write "extra" that if e.g. step[2]>step[1] for that reference value add in total value, else if step[1]>step[2] not add them and keep total as it is.
for references[1] in references:
cqlNodeQuery = ("MATCH (p1:Item),(p2:Item) where p1.value=$params RETURN p1.value AS from, p2.value AS to, gds.alpha.similarity.euclideanDistance((p1.embeddingNode2vec), (p2.embeddingNode2vec)) AS similarity order by similarity desc limit 20")
# Query the graph dynamically
nodes = graphDB_Session.run(cqlNodeQuery, params= references[1])
for node in nodes:
hey=[]
predictions = [node[1] for node in nodes]
step = [node[1] for node in nodes]
from collections import Counter
c1 = Counter(predictions)
total=0
# if step[1]<step[]
def rec_rank(key,dic):
total += dic[key]/float(sum(dic.values()))
return total
In my code, total is summed without regarding the step value. Could you please help me with this?
Aucun commentaire:
Enregistrer un commentaire