def format_data_for_team_avg_evolution(year):
    df = get_league(year)
    result = None
    for team in df.HomeTeam.unique():
        team_df = fc.get_team_matches(df, team)
        avgs = fc.get_team_avg_pts(df, team)
        points = fc.get_team_evolution(df, team)
        res = pd.DataFrame({\
                "Club":[team for i in range(0,team_df.shape[0])],
                "Date":team_df.Date,\
                "avg":avgs.values,\
                "m_avg_5":fc.get_team_mobile_avg_pts(df,team,n=5).values,
                "n":[i for i in range(0,team_df.shape[0])],\
                "pts":points.values})
        if result is None:
            result = res
        else:
            result = result.append(res)
    return result
Beispiel #2
0
def get_features_for_all_matches(year):
    db = format_data_for_team_avg_evolution(year)
    matches = get_league(year)\
            [fc.interesting_cols()]
    home_feats = merge_matches("HomeTeam", db, matches)
    home_feats = \
            get_only_feats_columns_renamed(\
            "home_",matches,home_feats)
    away_feats = merge_matches("AwayTeam", db, matches)
    away_feats = \
            get_only_feats_columns_renamed(\
            "away_",matches,away_feats)
    res = pd.concat([matches.reset_index(),\
            home_feats.reset_index(),away_feats.reset_index()]\
            ,axis=1)
    res["day"] = res["home_n"]
    res =  res.drop(columns=["index","Date","HomeTeam","AwayTeam"\
            ,"home_n","away_n"])
    res["target"] = res.apply(lambda x: categorize(x), axis=1)
    return res.loc[res.day > 0]
Beispiel #3
0
def test():
    db = format_data_for_team_avg_evolution(2014)
    matches = get_league(2014)
    return merge_matches("HomeTeam", db, matches)
def get_team_data_per_match(year):
    df = get_league(year)[-55:]
    db = format_data_for_team_avg_evolution(year)
def build_db(year):
    df = get_league(year)