Better Recommendation Generation
This commit is contained in:
parent
6e64e76310
commit
bd17ac4906
23
caliGraph.py
23
caliGraph.py
@ -634,12 +634,12 @@ def buildFullGraph(darkMode=False):
|
||||
graphAddTopLists(G, books, darkMode=darkMode)
|
||||
graphAddSeries(G, books, darkMode=darkMode)
|
||||
graphAddTags(G, books, darkMode=darkMode)
|
||||
runPagerank(G)
|
||||
return G, books
|
||||
|
||||
|
||||
def genScores(G, books):
|
||||
globMu, globStd = calcRecDist(G, books)
|
||||
runPagerank(G)
|
||||
scoreOpinions(G, globMu, globStd)
|
||||
scoreUnread(G, globMu, globStd)
|
||||
return globMu, globStd
|
||||
@ -708,16 +708,16 @@ def recommendNBooks(G, mu, std, n, removeTopListsB=True, removeUselessRecommende
|
||||
removeBad(G, mu+std/2, groups=['recommender'])
|
||||
removeKeepBest(G, int(n*2) + 5, maxDistForRead=2)
|
||||
removeEdge(G)
|
||||
removeHighSpanTags(G, 10)
|
||||
removeHighSpanReadBooks(G, 10)
|
||||
removeHighSpanTags(G, 8)
|
||||
removeHighSpanReadBooks(G, 14)
|
||||
removeDangling(G, alsoBooks=False)
|
||||
pruneRecommenders(G, 13)
|
||||
pruneTags(G, 13)
|
||||
pruneRecommenders(G, 16)
|
||||
pruneTags(G, 9)
|
||||
removeBad(G, mu, groups=['book'])
|
||||
removeUselessReadBooks(G)
|
||||
pruneTags(G, 12)
|
||||
pruneAuthorCons(G, int(n/5))
|
||||
pruneRecommenders(G, 12 - min(5, n/20))
|
||||
pruneTags(G, 8)
|
||||
pruneAuthorCons(G, int(n/5)+3)
|
||||
pruneRecommenders(G, 16 - min(4, n/20))
|
||||
removeUselessSeries(G, mu)
|
||||
removeUselessTags(G)
|
||||
if removeTopListsB:
|
||||
@ -911,7 +911,6 @@ def evaluateFitness(books, debugPrint=False):
|
||||
graphAddTopLists(G, books)
|
||||
graphAddSeries(G, books)
|
||||
graphAddTags(G, books)
|
||||
runPagerank(G)
|
||||
|
||||
ratedBooks = [n for n in list(G.nodes) if 'rating' in G.nodes[n] and G.nodes[n]['rating'] != None]
|
||||
boundsLoss = 0
|
||||
@ -946,8 +945,8 @@ def evaluateFitness(books, debugPrint=False):
|
||||
for g in gradient:
|
||||
gradient[g] /= len(errSq)
|
||||
if debugPrint:
|
||||
print(sum(errSq)/len(errSq), 0.003*regressionLoss, 0.2*boundsLoss/len(ratedBooks), 1.0*sum(linSepLoss)/len(linSepLoss))
|
||||
fit = sum(errSq)/len(errSq) + 0.003*regressionLoss + 0.2*boundsLoss/len(ratedBooks) - 1.0*sum(linSepLoss)/len(linSepLoss)
|
||||
print(sum(errSq)/len(errSq), 0.001*regressionLoss, 0.1*boundsLoss/len(ratedBooks), 0.5*sum(linSepLoss)/len(linSepLoss))
|
||||
fit = sum(errSq)/len(errSq) + 0.001*regressionLoss + 0.1*boundsLoss/len(ratedBooks) - 0.5*sum(linSepLoss)/len(linSepLoss)
|
||||
return fit, gradient
|
||||
|
||||
def train(initGamma, full=True):
|
||||
@ -992,7 +991,7 @@ def train(initGamma, full=True):
|
||||
gamma = initGamma
|
||||
if random.random() < 0.50:
|
||||
for wt in weights:
|
||||
weights[wt] = random.random()
|
||||
weights[wt] = random.random()*2-0.5
|
||||
else:
|
||||
weights = copy.copy(bestWeights)
|
||||
for wt in weights:
|
||||
|
Loading…
Reference in New Issue
Block a user