Created
May 15, 2015 12:38
-
-
Save springcoil/004f94ce65f4c3f1db3b to your computer and use it in GitHub Desktop.
Another Bayesian_Model which needs edited
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_hpd = pd.DataFrame(atts.stats()['95% HPD interval'], | |
columns=['hpd_low', 'hpd_high'], | |
index=teams.team.values) | |
df_median = pd.DataFrame(atts.stats()['quantiles'][50], | |
columns=['hpd_median'], | |
index=teams.team.values) | |
df_hpd = df_hpd.join(df_median) | |
df_hpd['relative_lower'] = df_hpd.hpd_median - df_hpd.hpd_low | |
df_hpd['relative_upper'] = df_hpd.hpd_high - df_hpd.hpd_median | |
df_hpd = df_hpd.sort_index(by='hpd_median') | |
df_hpd = df_hpd.reset_index() | |
df_hpd['x'] = df_hpd.index + .5 | |
fig, axs = plt.subplots(figsize=(10,4)) | |
axs.errorbar(df_hpd.x, df_hpd.hpd_median, | |
yerr=(df_hpd[['relative_lower', 'relative_upper']].values).T, | |
fmt='o') | |
axs.set_title('HPD of Attack Strength, by Team') | |
axs.set_xlabel('Team') | |
axs.set_ylabel('Posterior Attack Strength') | |
_= axs.set_xticks(df_hpd.index + .5) | |
_= axs.set_xticklabels(df_hpd['index'].values, rotation=45) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment