Beispiel #1
0
def get_single_factor(df, percentile):
    list_of_dicts = list()
    for team in unique_teams:
        df_ = df_helper.query_team(df, team)
        x = df_['TotalScore']
        # Position of percentile for x dataset
        p = np.percentile(x, percentile)
        # print("Team: {}, percentile: {}, pos: {}". format(team, percentile, p))
        # Filter df, only getting result out of percentile range
        percentile_df = filter_by_percentile(df_, percentile, p)
        # Create a frecuency dictionary from dataframe
        list_of_dicts.append(frecuencies_df(percentile_df, team))
    return sum_dicts(list_of_dicts)
Beispiel #2
0
def get_weighted_factors(df, percentile):
    list_of_dicts = list()
    for team in unique_teams:
        df_ = df_helper.query_team(df, team)
        x = df_['TotalScore']
        # Position of percentile for x dataset
        p = np.percentile(x, percentile)
        opo_p = np.percentile(x, oposite_percentile(percentile))
        width = abs(p - opo_p)
        # Filter df, only getting result out of percentile range
        teams_df = filter_by_percentile(df_, percentile, p)
        # Create a frecuency dictionary from dataframe
        list_of_dicts.append(weights_df(teams_df, team, p, width))
    return sum_dicts(list_of_dicts)
Beispiel #3
0
def normal_distribution(df, team, percentile=10):
    df_ = df_helper.query_team(df, team)

    x = df_['TotalScore']

    p_low = np.percentile(x, percentile)
    p_med = np.percentile(x, 50)
    p_high = np.percentile(x, 100 - percentile)

    mean = statistics.mean(x)
    sd = statistics.stdev(x)

    plt.plot(x, stats.norm.pdf(x, mean, sd))
    plt.title('{} normal deviation'.format(team))

    xposition = [p_low, p_med, p_high]
    for xc in xposition:
        plt.axvline(x=xc, color='r', linestyle='-')
    plt.show()
Beispiel #4
0
def percentile_team(df, team, percentile):
    df_ = df_helper.query_team(df, team)
    x = df_["TotalScore"]
    p = np.percentile(x, percentile)
    return p
Beispiel #5
0
def mean_team(df, team):
    df_ = df_helper.query_team(df, team)
    return df_['TotalScore'].mean()