Remove 'useless' read books from recommendation-graph (far away from all
unread books)
This commit is contained in:
parent
c31a3d78e2
commit
4fa3a57cc7
19
caliGraph.py
19
caliGraph.py
@ -276,6 +276,24 @@ def removeUnusedRecommenders(G):
|
|||||||
else: # No unrated recommendation
|
else: # No unrated recommendation
|
||||||
G.remove_node(n)
|
G.remove_node(n)
|
||||||
|
|
||||||
|
def removeUselessReadBooks(G):
|
||||||
|
for n in list(G.nodes):
|
||||||
|
node = G.nodes[n]
|
||||||
|
if node['t'] == 'book':
|
||||||
|
for adj in G.adj[n]:
|
||||||
|
foundUnread = True
|
||||||
|
adjNode = G.nodes[adj]
|
||||||
|
for cousin in G.adj[adj]:
|
||||||
|
cousinNode = G.nodes[cousin]
|
||||||
|
if cousinNode['t']=='book' and 'score' in cousinNode:
|
||||||
|
break
|
||||||
|
else: # No unrated book here
|
||||||
|
foundUnread = False
|
||||||
|
if foundUnread:
|
||||||
|
break
|
||||||
|
else: # No unrated book in cousins
|
||||||
|
G.remove_node(n)
|
||||||
|
|
||||||
def scoreOpinions(G, globMu, globStd, errorFac=0.5):
|
def scoreOpinions(G, globMu, globStd, errorFac=0.5):
|
||||||
for n in list(G.nodes):
|
for n in list(G.nodes):
|
||||||
node = G.nodes[n]
|
node = G.nodes[n]
|
||||||
@ -517,6 +535,7 @@ def recommendNBooks(G, mu, std, n, removeTopListsB=True, removeUselessRecommende
|
|||||||
removeDangling(G, alsoBooks=False)
|
removeDangling(G, alsoBooks=False)
|
||||||
pruneTags(G, 6)
|
pruneTags(G, 6)
|
||||||
removeBad(G, mu, groups=['book'])
|
removeBad(G, mu, groups=['book'])
|
||||||
|
removeUselessReadBooks(G)
|
||||||
pruneTags(G, 4.25)
|
pruneTags(G, 4.25)
|
||||||
pruneRecommenderCons(G, int(n/7)+1)
|
pruneRecommenderCons(G, int(n/7)+1)
|
||||||
pruneAuthorCons(G, int(n/15))
|
pruneAuthorCons(G, int(n/15))
|
||||||
|
Loading…
Reference in New Issue
Block a user