示例#1
0
def make_transfers_section():
    margin_style = {"margin-top": "1rem", "margin-bottom": "2rem"}
    config = load_config()
    data_loader = DataLoader(config)
    df_league = data_loader.get_league_standings()
    manager_ids = df_league["entry_id"].unique().tolist()
    manager_names = df_league["entry_name"].unique().tolist()
    manager_options = [{
        'label': manager,
        'value': manager_id
    } for manager, manager_id in zip(manager_names, manager_ids)]
    dropdown_manager = make_dropdown('manager-selection-transfers',
                                     manager_options,
                                     placeholder="Select Manager ...")
    num_transfers = [1, 2, 3, 4]
    transfer_options = [{'label': num, 'value': num} for num in num_transfers]
    dropdown_num_transfers = make_dropdown(
        'transfer-selection-numbers',
        transfer_options,
        placeholder="Select number of transfers ...")

    dropdown_section = html.Div(children=[
        html.Div(dropdown_manager, className='col-6'),
        html.Div(dropdown_num_transfers, className='col-6'),
    ],
                                className='row')
    section = html.Div(children=[
        html.Div("Transfer Suggestion", className='subtitle inline-header'),
        dropdown_section,
        html.Div(make_button("Submit", 'transfer-optimization-btn')),
        dcc.Loading(html.Div(id='transfer-suggestion-output',
                             style=margin_style),
                    color='black')
    ])
    return section
示例#2
0
def make_player_comparison_section():
    margin_style = {"margin-top": "1rem", "margin-bottom": "2rem"}
    data_maker = ModelDataMaker(CONFIG_2020)
    player_id_player_name_map = data_maker.get_player_id_player_name_map()
    player_names = []
    for k, v in player_id_player_name_map.items():
        player_names.append(v)
    player_names = sorted(list(set(player_names)))
    player_options = [{
        'label': player,
        'value': player
    } for player in player_names]
    dropdown_player_a = make_dropdown('player-selection-dropdown-a',
                                      player_options,
                                      placeholder="Select Player ...")
    dropdown_player_b = make_dropdown('player-selection-dropdown-b',
                                      player_options,
                                      placeholder="Select Player ...")

    player_dropdown_section = html.Div(children=[
        html.Div(dropdown_player_a, className='col-6'),
        html.Div(dropdown_player_b, className='col-6'),
    ],
                                       className='row')
    section = html.Div(children=[
        html.Div("Player Comparison", className='subtitle inline-header'),
        player_dropdown_section,
        html.Div(id='player-compare-output', style=margin_style)
    ])
    return section
示例#3
0
def make_optimization_settings_section():
    margin_style = {"margin-top": "1rem", "margin-bottom": "2rem"}
    next_gw = query_next_gameweek()
    focus_gws = [next_gw - 2, next_gw - 1, next_gw]
    gw_options = [{'label': gw_id, 'value': gw_id} for gw_id in focus_gws]
    dropdown_gw = make_dropdown('gw-selection-dropdown-squad',
                                gw_options,
                                placeholder="Select Gameweek ...")

    ai_models = [
        "LGBM Point", "LGBM Potential", "LGBM Return", "Fast Point",
        "Fast Potential", "Fast Return", "Net"
    ]
    model_options = [{'label': model, 'value': model} for model in ai_models]
    dropdown_model = make_dropdown('model-selection-dropdown-optim',
                                   model_options,
                                   placeholder="Select Model ...")

    formations = ['1-3-4-3', '1-3-5-2', '1-4-4-2', '1-4-3-3']
    formation_options = [{
        'label': this_formation,
        'value': this_formation
    } for this_formation in formations]
    dropdown_formation = make_dropdown('formation-selection-dropdown-squad',
                                       formation_options,
                                       placeholder="Select Formation ...")
    dropdown_section = html.Div(children=[
        html.Div(dropdown_gw, className='col-4'),
        html.Div(dropdown_model, className='col-4'),
        html.Div(dropdown_formation, className='col-4'),
    ],
                                className='row')

    budget_header = html.Div(children=[
        html.Div("Enter Squad Value", className='col-4'),
        html.Div("Enter Bench Value", className='col-4'),
        html.Div("Exclude Uncertain Players", className='col-4'),
    ],
                             className='row')

    budget_section = html.Div(children=[
        html.Div(make_input('squad-value-input', 'number', 100),
                 className='col-4'),
        html.Div(make_input('bench-value-input', 'number', 18),
                 className='col-4'),
        html.Div(make_input('uncertain-flag', 'text', "Yes"),
                 className='col-4'),
    ],
                              className='row')

    section = html.Div(children=[
        dropdown_section, budget_header, budget_section,
        html.Div(make_button("Submit", 'squad-optimization-btn')),
        html.Div(" ", style={
            "margin-top": "6rem",
            "margin-bottom": "6rem"
        })
    ])
    return section
示例#4
0
def make_lead_generation_section():
    margin_style = {"margin-top": "1rem", "margin-bottom": "2rem"}
    data_maker = ModelDataMaker(CONFIG_2020)
    team_id_team_name_map = data_maker.get_team_id_team_name_map()
    team_names = []
    for k, v in team_id_team_name_map.items():
        team_names.append(v)
    team_names = list(set(team_names))
    team_names.append("All")
    team_names = sorted(team_names)

    team_options = [{'label': team, 'value': team} for team in team_names]
    dropdown_team = make_dropdown('team-selection-dropdown-leads',
                                  team_options,
                                  placeholder="Select Team ...")

    ai_models = [
        "LGBM Point", "LGBM Potential", "LGBM Return", "Fast Point",
        "Fast Potential", "Fast Return"
    ]
    model_options = [{'label': model, 'value': model} for model in ai_models]
    dropdown_model = make_dropdown('model-selection-dropdown-leads',
                                   model_options,
                                   placeholder="Select Model ...")
    dropdown_section = html.Div(children=[
        html.Div(dropdown_team, className='col-6'),
        html.Div(dropdown_model, className='col-6'),
    ],
                                className='row')

    leads_output = html.Div(children=[
        html.Div("GK", className='subtitle inline-header'),
        dcc.Loading(html.Div(id='gk-leads', style=margin_style),
                    color='black'),
        html.Div("DEF", className='subtitle inline-header'),
        dcc.Loading(html.Div(id='def-leads', style=margin_style),
                    color='black'),
        html.Div("MID", className='subtitle inline-header'),
        dcc.Loading(html.Div(id='mid-leads', style=margin_style),
                    color='black'),
        html.Div("FWD", className='subtitle inline-header'),
        dcc.Loading(html.Div(id='fwd-leads', style=margin_style),
                    color='black')
    ])

    section = html.Div(children=[
        html.Div("Select Team & Model", className='subtitle inline-header'),
        dropdown_section, leads_output
    ])
    return section
示例#5
0
def make_league_search_section():
    config = load_config()
    league_ids = config["leagues"]
    league_options = [{'label': this_id, 'value': this_id} for this_id in league_ids]
    dropdown_section = make_dropdown('league-search-dropdown', league_options,
                                     placeholder="Select League ID ...")
    return dropdown_section
示例#6
0
def make_gw_selection_section():
    next_gw = query_next_gameweek()
    focus_gws = [next_gw - 2, next_gw - 1, next_gw]
    gw_options = [{'label': gw_id, 'value': gw_id} for gw_id in focus_gws]
    dropdown_section = make_dropdown('gw-selection-dropdown',
                                     gw_options,
                                     placeholder="Select Gameweek ID ...")
    return dropdown_section
示例#7
0
def make_shap_explanation_section():
    margin_style = {"margin-top": "1rem", "margin-bottom": "2rem"}
    data_maker = ModelDataMaker(CONFIG_2020)
    player_id_player_name_map = data_maker.get_player_id_player_name_map()
    player_names = []
    for k, v in player_id_player_name_map.items():
        player_names.append(v)
    player_names = sorted(list(set(player_names)))

    player_options = [{
        'label': player,
        'value': player
    } for player in player_names]
    dropdown_player = make_dropdown('player-selection-dropdown-shap',
                                    player_options,
                                    placeholder="Select Player ...")

    ai_models = ["LGBM Point", "LGBM Potential", "LGBM Return"]
    model_options = [{'label': model, 'value': model} for model in ai_models]
    dropdown_model = make_dropdown('model-selection-dropdown-shap',
                                   model_options,
                                   placeholder="Select Model ...")
    dropdown_section = html.Div(children=[
        html.Div(dropdown_player, className='col-6'),
        html.Div(dropdown_model, className='col-6'),
    ],
                                className='row')

    shap_output = html.Div(children=[
        dcc.Loading(html.Div(id='shap-output', style=margin_style),
                    color='black'),
    ])

    section = html.Div(children=[
        # html.Div("Select Player & Model", className='subtitle inline-header'),
        dropdown_section,
        shap_output
    ])
    return section
示例#8
0
def make_right_layout_league():
    header = make_header("League Analytics")
    dropdown_section = make_dropdown('league-team-picks-dropdown', None,
                                     placeholder="Select FPL Team ...", multi_flag=False)
    layout = html.Div(
        id='league-layout-left',
        className="six columns",
        children=[
            header,
            html.Div("Team Picks", className='subtitle inline-header'),
            dropdown_section,
            dcc.Loading(html.Div(id="league-team-picks-display"), color='black'),
            dcc.Loading(html.Div(id="league-team-xp-output"), color='black'),
        ],
    )
    return layout
示例#9
0
def make_left_layout_league():
    header = make_header("League Standing")
    dropdown_section = make_dropdown('team-selection-dropdown', None,
                                     placeholder="Select Teams For Comparison ...", multi_flag=True)
    layout = html.Div(
        id='league-layout-left',
        className="six columns",
        children=[
            header,
            html.Div("League Summary", className='subtitle inline-header'),
            make_league_search_section(),
            html.Div(id="league-standing-table", style={"width": "100%"}),
            dcc.Store(id="league-standing-memory"),
            html.Div("League Gameweek History", className='subtitle inline-header'),
            dropdown_section,
            html.Div(id="league-point-history", style={"width": "100%"})
        ],
    )
    return layout