def wk_error(wk): sum = 0 get_games() ratings = read_ratings_file(wk) wk_games = [] print('week ', wk) print(len(fb.games), ' total games') for game in fb.games: if game[4] == wk + 1: wk_games.append(game) print(len(wk_games), ' games') nwin = 0 for game in wk_games: p_score = fb.predict_score(game[0], game[1], ratings) p_spread = p_score[0] - p_score[1] r_spread = game[2] - game[3] if p_spread < 0 and r_spread < 0: nwin += 1 if p_spread > 0 and r_spread > 0: nwin += 1 diff = (p_spread - r_spread) #print(p_spread, r_spread, diff) sum += diff*diff #print(sum, len(wk_games)) ave = sum/len(wk_games) ave = math.sqrt(ave) print('points off per game:', ave) per = 100 * nwin/len(wk_games) print("predict right winner ", nwin, " out of ", len(wk_games), per)
def test_predict(): read_info_file() ratings = read_ratings_file(13) print(fb.teams) ratings = fb.compute_ratings(13) input1 = 'Boise State' input2 = 'Air Force' t1 = fb.teams.index(input1) t2 = fb.teams.index(input2) p = fb.predict_score(t1, t2, ratings) print(input1, p[0], input2, p[1])