Пример #1
0
def predict_stage():
    past_games, future_games = load_games()

    predictor = PlayerTrueSkillPredictor()
    predictor.train_games(past_games)

    p_stage = predictor.predict_stage(future_games)
    teams = sorted(p_stage.keys(),
                   key=lambda team: p_stage[team][-1],
                   reverse=True)

    print(predictor.base_stage)
    print(f'       Top3   Top1  Roster')
    for team in teams:
        p_top3, p_top1 = p_stage[team]

        if isinstance(p_top3, bool):
            top3 = str(p_top3)
        else:
            top3 = f'{round(p_top3 * 100)}%'

        if isinstance(p_top1, bool):
            top1 = str(p_top1)
        else:
            top1 = f'{round(p_top1 * 100)}%'

        roster = ' '.join(predictor.best_rosters[team])

        print(f'{team:>4}  {top3:>5}  {top1:>5}  {roster}')
Пример #2
0
def compare_methods() -> None:
    games, _ = load_games()
    classes = [SimplePredictor, TrueSkillPredictor, PlayerTrueSkillPredictor]

    for class_ in classes:
        predictor = class_()
        avg_point = predictor.train_games(games) / len(games)
        avg_accuracy = np.sum(np.array(predictor.corrects)) / len(games)
        print(f'{class_.__name__:>30} {avg_point:8.4f} {avg_accuracy:7.3f}')
Пример #3
0
def optimize_beta(class_=PlayerTrueSkillPredictor, maxfun=100) -> None:
    games, _ = load_games()

    def f(x):
        predictor = class_(beta=x[0])
        return -predictor.train_games(games)

    args = fmin(f, [2500.0 / 6.0], maxfun=maxfun)
    avg_point = -f(args) / len(games)
    print(f'beta = {args[0]:.0f}, avg(point) = {avg_point:.4f}')
Пример #4
0
def optimize_draw_probability(class_=PlayerTrueSkillPredictor,
                              maxfun=100) -> None:
    games, _ = load_games()

    def f(x):
        predictor = class_(draw_probability=x[0])
        predictor.train_games(games)
        return (predictor.expected_draws - predictor.real_draws)**2

    args = fmin(f, [0.06], maxfun=maxfun)
    print(f'draw_probability = {args[0]:.3f}')
Пример #5
0
def render_all():
    past_games, future_matches = load_games()

    predictor = PlayerTrueSkillPredictor()
    match_cards = render_match_cards(predictor, past_games, future_matches)
    predictor.save_ratings_history()

    render_index(predictor, future_matches)
    render_matches(match_cards)
    render_teams(predictor, match_cards)
    render_about(predictor)
Пример #6
0
def predict_stage():
    past_games, future_matches = load_games()

    predictor = PlayerTrueSkillPredictor()
    predictor.train_games(past_games)

    p_stage = predictor.predict_stage(future_matches)
    # p_season = predictor.predict_season(future_matches)
    teams = sorted(p_stage.keys(),
                   key=lambda team: p_stage[team][-1],
                   reverse=True)

    print(predictor.base_stage)
    print(f'      Title   Top1  Roster')
    for team in teams:
        p_title, p_top1 = p_stage[team]
        # p_season_top6, p_season_top1 = p_season[team]

        if isinstance(p_title, bool):
            title = str(p_title)
        else:
            title = f'{round(p_title * 100)}%'

        if isinstance(p_top1, bool):
            top1 = str(p_top1)
        else:
            top1 = f'{round(p_top1 * 100)}%'

        # if isinstance(p_season_top6, bool):
        #     season_top6 = str(p_season_top6)
        # else:
        #     season_top6 = f'{round(p_season_top6 * 100)}%'

        # if isinstance(p_season_top1, bool):
        #     season_top1 = str(p_season_top1)
        # else:
        #     season_top1 = f'{round(p_season_top1 * 100)}%'

        roster = ' '.join(predictor.best_rosters[team])

        print(f'{team:>4}  {title:>5}  {top1:>5}  {roster}')
Пример #7
0
def save_ratings():
    past_games, future_games = load_games()

    predictor = PlayerTrueSkillPredictor()
    predictor.train_games(past_games)
    predictor.save_ratings_history()