Tweaked training
This commit is contained in:
parent
cf85995386
commit
fb3a5592df
11
caliGraph.py
11
caliGraph.py
@ -682,6 +682,9 @@ def evaluateFitness():
|
|||||||
rating = G.nodes[m]['rating']
|
rating = G.nodes[m]['rating']
|
||||||
G.nodes[m]['rating'] = None
|
G.nodes[m]['rating'] = None
|
||||||
mu, std = genScores(G, books)
|
mu, std = genScores(G, books)
|
||||||
|
if G.nodes[m]['score'] > rating: # over estimated
|
||||||
|
errSq.append(((rating - G.nodes[m]['score'])**2)*1.5)
|
||||||
|
else:
|
||||||
errSq.append((rating - G.nodes[m]['score'])**2)
|
errSq.append((rating - G.nodes[m]['score'])**2)
|
||||||
G.nodes[m]['rating'] = rating
|
G.nodes[m]['rating'] = rating
|
||||||
return sum(errSq) / len(errSq)
|
return sum(errSq) / len(errSq)
|
||||||
@ -697,11 +700,17 @@ def train(gamma = 0.1):
|
|||||||
while True:
|
while True:
|
||||||
print({'mse': best_mse, 'w': weights, 'gamma': gamma})
|
print({'mse': best_mse, 'w': weights, 'gamma': gamma})
|
||||||
weights = copy.copy(bestWeights)
|
weights = copy.copy(bestWeights)
|
||||||
|
if gamma < 0.01 and random.random() < 0.5:
|
||||||
|
gamma = 0.01
|
||||||
|
weights[attr] = -1+random.random()*2
|
||||||
|
else:
|
||||||
weights[attr] += delta
|
weights[attr] += delta
|
||||||
|
if attr not in ['sigma, mu']:
|
||||||
|
weights[attr] = min(max(0, weight[attr]), 1.5)
|
||||||
mse = evaluateFitness()
|
mse = evaluateFitness()
|
||||||
if mse < best_mse: # got better
|
if mse < best_mse: # got better
|
||||||
saveWeights(weights)
|
saveWeights(weights)
|
||||||
gamma *= 1.1
|
gamma *= 1.75
|
||||||
bestWeights = copy.copy(weights)
|
bestWeights = copy.copy(weights)
|
||||||
best_mse = mse
|
best_mse = mse
|
||||||
delta *= 2
|
delta *= 2
|
||||||
|
Loading…
Reference in New Issue
Block a user