diff --git a/caliGraph.py b/caliGraph.py index f968712..20bc8fb 100755 --- a/caliGraph.py +++ b/caliGraph.py @@ -428,8 +428,8 @@ def scoreUnread(G, globMu, globStd): #ws.append(['tgb_rank']) feedbacks.append(node['std']) ws.append(['sigma']) - #feedbacks.append(node['median']) - #ws.append(['median']) + feedbacks.append(node['median']) + ws.append(['median']) #feedbacks.append(node['se']) #ws.append(['se']) feedbacks.append(globMu) @@ -1266,7 +1266,7 @@ def train(initGamma, full=True): print({'mse': mse, 'gamma': gamma, 'delta': delta}) delta = sum(gradient[g]**2 for g in gradient) for wt in weights: - weights[wt] += gamma*gradient[wt]/math.sqrt(delta) + weights[wt] += gamma*0.1*gradient[wt]/math.sqrt(delta) mse, gradient = evaluateFitness(books) if mse < last_mse: gamma = gamma*1.25 @@ -1304,7 +1304,7 @@ def loadWeights(): with open('neuralWeights.json', 'r') as f: weights = json.loads(f.read()) except IOError: - weights = {"topList": 0.15, "recommender": 0.30, "author": 0.70, "series": 0.05, "tag": 0.05, "pagerank": 0.05, "mu": 0.50, "sigma": 0.30, "bias": 0.25} #, "tgb_rank": 0.10} + weights = {"topList": 0.15, "recommender": 0.30, "author": 0.70, "series": 0.05, "tag": 0.05, "pagerank": 0.05, "mu": 0.50, "sigma": 0.30, "bias": 0.25, "median": 0.10} #, "tgb_rank": 0.10} return weights def cliInterface(): @@ -1324,6 +1324,7 @@ def cliInterface(): parser.add_argument('--v3d', action="store_true") parser.add_argument('--imgs', action="store_true") parser.add_argument('--perf-test', action="store_true") + parser.add_argument('--train', action="store_true") cmds = parser.add_subparsers(required=True, dest='cmd') p_rec = cmds.add_parser('recommend', description="TODO", aliases=['rec']) @@ -1387,6 +1388,9 @@ def mainCLI(args): train(args.g, args.full) exit() + if args.train: + train(0.2, False) + bestListT = 'book' G, books = buildFullGraph(darkMode=args.dark)