More GNTM

This commit is contained in:
Dominik Moritz Roth 2022-02-24 22:29:52 +01:00
parent e87288a927
commit 02e912d4ff
2 changed files with 6 additions and 7 deletions

View File

@ -403,8 +403,7 @@ def scoreOpinions(G, globMu, globStd):
node['score'] = node['mean'] node['score'] = node['mean']
node['feedbacks'] = feedbacks node['feedbacks'] = feedbacks
else: else:
node['score'] = globMu - globStd node['score'] = None
node['score'] = node['score'] / 2 + node['gpr_score']
def scoreUnread(G, globMu, globStd): def scoreUnread(G, globMu, globStd):
for n in list(G.nodes): for n in list(G.nodes):
@ -817,7 +816,7 @@ def genScores(G, books, calcPagerank=True):
globMu, globStd = calcRecDist(G, books) globMu, globStd = calcRecDist(G, books)
if calcPagerank: if calcPagerank:
runPagerank(G) runPagerank(G)
genGprScores(G, globMu, globStd, 'score', 'std') genGprScores(G, globMu, globStd, 'score', 'se')
#scoreOpinions(G, globMu, globStd) #scoreOpinions(G, globMu, globStd)
#scoreUnread(G, globMu, globStd) #scoreUnread(G, globMu, globStd)
return globMu, globStd return globMu, globStd

View File

@ -62,14 +62,14 @@ def genGprScores(G, globMu, globStd, scoreName='gpr_score', stdName='gpr_std'):
X = [] X = []
for n in G.nodes: for n in G.nodes:
node = G.nodes[n] node = G.nodes[n]
if 'rating' in node and node['rating']==None: if not 'rating' in node or node['rating']==None:
X.append(n) X.append(n)
print('[\] Inferencing GP') print('[\] Inferencing GP')
y, stds = gpr.predict(X, return_std=True) y, stds = gpr.predict(X, return_std=True)
i=0 i=0
for n in G.nodes: for n in G.nodes:
node = G.nodes[n] node = G.nodes[n]
if 'rating' in node and node['rating']==None: if not 'rating' in node or node['rating']==None:
s, std = y[i], stds[i] s, std = y[i], sum([val[0] for val in stds[i]])
i+=1 i+=1
node[scoreName], node[stdName] = s, std node[scoreName], node[stdName] = float(s), float(std)