From 3032dea8a0541fa82f410bb0a6f2af3b5c528132 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 6 Feb 2022 18:22:46 +0100 Subject: [PATCH] Better rankings-list in cli and newly trained net --- caliGraph.py | 32 +++++++++++++++++++++++--------- neuralWeights.json | 2 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/caliGraph.py b/caliGraph.py index b445f91..8865975 100755 --- a/caliGraph.py +++ b/caliGraph.py @@ -446,17 +446,21 @@ def getWeightForType(nodeType, edgeWeight=1): else: return w -def printBestList(G, num=-1): +def printBestList(G, t='book', num=-1): + print(t) bestlist = [] for n in list(G.nodes): node = G.nodes[n] - if node['t'] == 'book': + if node['t'] == t: if 'score' in node and node['score'] != None: bestlist.append(node) - bestlist.sort(key=lambda node: node['score'], reverse=True) + bestlist.sort(key=lambda node: node['score'] + 0.00001*(node['se'] if 'se' in node else 0), reverse=True) for i, book in enumerate(bestlist): - print("["+str(i+1).zfill(int((math.log10(num) if num!=-1 else 3)+1))+"] "+book['title'] + - " ("+" & ".join(book['authors'])+"): {:.5f}".format(book['score'])) + if t=='book': + line = book['title'] + " ("+" & ".join(book['authors'])+")"+": {:.5f}".format(book['score']) + else: + line = book['label'] + print("["+str(i+1).zfill(int((math.log10(num) if num!=-1 else 3)+1))+"] "+line) if num!=-1 and i == num-1: break @@ -804,9 +808,17 @@ def recommenderCompetence(G): removeSeries(G) removeTopLists(G) + removeEdge(G) + removeDangling(G, alsoBooks=True) + scaleBooksByRating(G) scaleOpinionsByRating(G) addScoreToLabels(G) + + for n in list(G.nodes): + node = G.nodes[n] + if node['t'] == 'recommender': + node['score'] -= node['se'] * 1 def readBooksAnalysis(G, minRating=0, showAllTags=True, removeUnconnected=False, removeTopListsB=True): removeUnread(G) @@ -1170,6 +1182,8 @@ def cliInterface(): train(args.g, args.full) exit() + bestListT = 'book' + G, books = buildFullGraph(darkMode=args.dark_mode) mu, std = genScores(G, books) @@ -1199,20 +1213,20 @@ def cliInterface(): elif args.cmd=="full": fullGraph(G, not args.keep_top_lists) elif args.cmd=="competence": + bestListT = 'recommender' recommenderCompetence(G) elif args.cmd=="shell": shell(G, books, mu, std) - elif args.cmd=="competence": - recommenderCompetence(G) - return elif args.cmd=="progress": progress(G, args.m) return elif args.cmd=="newBooks": + bestListT = 'newBook' newBooks(G, books, args.n, mu, std) else: raise Exception("Bad") + if not args.keep_priv: removePriv(G) if args.remove_read: @@ -1226,7 +1240,7 @@ def cliInterface(): removeEdge(G) if not args.no_list: - printBestList(G) + printBestList(G, t=bestListT) if not args.no_web and not args.cmd in ['listScores']: genAndShowHTML(G, darkMode=args.dark_mode) diff --git a/neuralWeights.json b/neuralWeights.json index 5a2089b..addbfab 100644 --- a/neuralWeights.json +++ b/neuralWeights.json @@ -1 +1 @@ -{"topList": 0.020357663923899313, "recommender": 0.3428529069584538, "author": 1.288739952769999, "series": 0.6484880619815447, "tag": 0.026296102297284726, "pagerank": 0.011025414086463162, "mu": 1.1052719819984915, "sigma": 0.5964842267419479, "bias": 0.0346189601467517} \ No newline at end of file +{"topList": 0.008877350797718757, "recommender": 0.3310976523405012, "author": 1.2297781106971182, "series": 0.6295690756530204, "tag": 0.029071357518799894, "pagerank": 0.011066788616739529, "mu": 1.1289465103781409, "sigma": 0.6694694643304658, "bias": 0.03536567416040619} \ No newline at end of file