Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
with pm.Model() as curve_spin_model: | |
spin = pm.Data('spin', curveball_data['spin_rate']) | |
β = pm.Normal('β', shape=2) | |
θ = β[0] + β[1]*(spin/1000) | |
swing_miss = pm.Data('swing_miss', curveball_data['miss']) | |
miss = pm.Bernoulli('miss', pm.invlogit(θ), observed=swing_miss) |
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 = pd.DataFrame(dict(y=np.array([2, 4, 2, 0, 4]))) | |
with pm.Model() as glm: | |
x = np.array([0.3, 1.1, 0.6, -0.2, 3.3]) | |
pm.glm.GLM.from_formula('y ~ x', data=df, family=pm.glm.families.Poisson()) |
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
more_curves = [1810, 2225, 3015] | |
with curve_spin_model: | |
pm.set_data({'spin': more_curves}) | |
post_pred = pm.sample_posterior_predictive(trace, samples=1000) |
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
traces = {} | |
for year in years: | |
with curve_spin_model: | |
year_data = curveball_data.query('year==@year') | |
pm.set_data({'spin': year_data.spin_rate, | |
'swing_miss': year_data.miss}) | |
traces[year] = pm.sample(1000, tune=2000, | |
cores=2, progressbar=False) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.