Esempio n. 1
0
    def plot_histogram_with_dummies_theoretical(self):
        if not self.clustering:
            raise ValueError('Clustering not performed yet')

        new_histogram, full_histogram = utils.build_clustered_histograms(
            self.histogram, self.labels)
        utils.plot_histograms(original_histogram=new_histogram,
                              theoretical_dummies=full_histogram)
Esempio n. 2
0
    def plot_histogram_with_dummies_real(self):
        if not self.dummies:
            raise ValueError('Dummies not generated yet')

        _, theoretical_dummies = utils.build_clustered_histograms(
            self.histogram, self.labels)
        histogram_with_dummies = self.patient_concepts_matrix_dummies.sum(0)

        cluster_indexing = theoretical_dummies.index

        utils.plot_histograms(self.histogram[cluster_indexing],
                              theoretical_dummies[cluster_indexing],
                              histogram_with_dummies[cluster_indexing])
Esempio n. 3
0
# print(data.head())

data = data[data['Year'] < 2002]
data['RD'] = data['RS'] - data['RA']
in_playoffs = data[data['Playoffs'] == 1]
out_playoffs = data[data['Playoffs'] == 0]

from utils import plot_scatters, plot_histograms, plot_deriving_slope
plot_scatters(in_playoffs, out_playoffs, label='RS')
plot_scatters(in_playoffs,
              out_playoffs,
              label='RD',
              RDxline=False,
              x=data['RD'].values,
              y=data['W'].values)
plot_histograms(data)
# plot_deriving_slope(data['RD'].values, data['W'].values)
from matplotlib import pyplot as plt
plt.show()
rd_to_wins = data[['RD', 'W']].corr()

dePodesta = data[['OBP', 'SLG', 'BA', 'RS']].corr()
from sklearn.linear_model import LinearRegression

modelRS = LinearRegression()
modelRS.fit(data[['OBP', 'SLG']].values, data['RS'].values)

print(f"bias RS: {modelRS.intercept_}")
print(f"Coefficients: {modelRS.coef_}")

RA_data = data.dropna()
Esempio n. 4
0
 def plot_histogram(self):
     utils.plot_histograms(original_histogram=self.histogram)
Esempio n. 5
0
        plt.figure(3)
        plt.plot(np.arange(T), opt_arms_rate_mean, label=algo)
        plt.fill_between(time,
                         opt_arms_rate_mean -
                         (q / np.sqrt(n_itr)) * np.sqrt(opt_arms_rate_var),
                         opt_arms_rate_mean +
                         (q / np.sqrt(n_itr)) * np.sqrt(opt_arms_rate_var),
                         color='#D3D3D3')
        plt.xlabel('Rounds')
        plt.ylabel('$\%$')
        plt.title('Rate of optimal arms pulling, averaged over ' + str(n_itr) +
                  ' runs')
        plt.legend()

    if plot_histo:
        fig = plot_histograms(algo, histograms, hist_times, K, A_star)

alpha_star, opt_mix_rew = MO_MAB.alpha_star, MO_MAB.optimal_mixed_rew
print('Optimal mixed reward = ' + str(opt_mix_rew))

alpha = ogde.alpha.reshape((1, K))
opt_mix = alpha.dot(MO_MAB.O)[0]
print('Mixed reward at time T = ' + str(opt_mix))
print('')
print('Alpha_star = ' + str(alpha_star))
print('Alpha_T = ' + str(alpha[0]))

if plot_arms and D in [2, 3]:
    plot_momab(MO_MAB,
               opt_mix,
               alpha_ogde=alpha_ogde,
Esempio n. 6
0
    print("You didn't specify any plot types, exiting")
    sys.exit(1)

connectstring = dbutils.make_connectstring(db="views",
                                           hostname="VIEWSHOST",
                                           port="5432",
                                           prefix="postgres",
                                           uname="VIEWSADMIN")

dir_descriptive = "/storage/runs/current/descriptive"
dir_table = "/".join([dir_descriptive, schema, table])

df = dbutils.db_to_df(connectstring, schema, table, ids=[timevar, groupvar])
df.sort_index(inplace=True)

if plot_wawa:
    utils.plot_world_average_with_actuals(df, connectstring, dir_table,
                                          timevar, groupvar)
if plot_spaghetti:
    utils.plot_spaghetties(df, connectstring, dir_table)
if plot_hist:
    utils.plot_histograms(df, dir_table)
if plot_lpg:
    utils.plot_lines_per_group(df, dir_table)
if plot_abt:
    utils.plot_stats_by_time(df, dir_table)
if plot_pgcm:
    utils.plot_pgcm(df, connectstring, dir_table)
if plot_lpgwa:
    utils.plot_lines_per_group_with_actuals(df, connectstring, dir_table)