PPC with the Hierarchical model for Rugby prediction exam[;e
I've been experimenting with PPC on the hierarchical model for rugby prediction example to see if I can if it can be used to predict fictional games.
First, I think there is a minor mistake in the example. Where
home_theta = tt.exp(intercept + home + atts[away_team] + defs[home_team])
it should be:
home_theta = tt.exp(intercept + home + atts[home_team] + defs[away_team])
Second, when I run sample_ppc after replacing the home_team/away_team values, I receive the number of results that was used 'train'/sample the model, not the output expected:
I split the data between train and test, and encapsulate train data in the shared theano object.
df_test = df[:5]
df_train = df[5:100]
home_team = shared(df_train.i_home.values)
away_team = shared(df_train.i_away.values)
After sampling the data I replace the data in the shared theano object with the new data.
home_team = shared(df_test.i_home.values)
away_team = shared(df_test.i_away.values)
ppc = pm.sample_ppc(trace, model=model, samples=500)
The number of results I get are larger than I expect:
ppc['home_points'].shape
(500, 95)
Hi Shaun, I'll fix up that error when I next can.
I see nothing a priori wrong with your approach. Home_Points could be the total number of points scored in one game if I remember correctly.
I'll check.
On Mon, Feb 29, 2016 at 2:42 PM, ShaunBristol [email protected] wrote:
I've been experimenting with PPC on the hierarchical model for rugby prediction example to see if I can if it can be used to predict fictional games.
First, I think there is a minor mistake in the example. Where home_theta = tt.exp(intercept + home + atts[away_team] + defs[home_team]) it should be: home_theta = tt.exp(intercept + home + atts[home_team] + defs[away_team])
Second, when I run sample_ppc after replacing the home_team/away_team values, I receive the number of results that was used 'train'/sample the model, not the output expected:
I split the data between train and test, and encapsulate train data in the shared theano object.
df_test = df[:5] df_train = df[5:100] home_team = shared(df_train.i_home.values) away_team = shared(df_train.i_away.values)
After sampling the data I replace the data in the shared theano object with the new data.
home_team = shared(df_test.i_home.values) away_team = shared(df_test.i_away.values) ppc = pm.sample_ppc(trace, model=model, samples=500)
The results i get are larger than I expect: ppc['home_points'].shape (500, 95)
— Reply to this email directly or view it on GitHub https://github.com/pymc-devs/pymc3/issues/1001.
Peadar Coyle Skype: springcoilarch www.twitter.com/springcoil peadarcoyle.wordpress.com
Hi, Thanks for responding. Home points is the score for the home side. However, the shape I would expect the results from sample_ppc would reflect the testing data (of 5 entries) which would be (500, 5). Instead I get (500, 95) which reflects the training data (95 entries).
home_team = shared(df_test.i_home.values)
away_team = shared(df_test.i_away.values)
ppc = pm.sample_ppc(trace, model=model, samples=500)
To set values you'd use home_team.set_value() rather than just instantiating a new shared object.
Thanks, that was the problem.
You could add that as an example to the Notebook if you wanted Shaun or even in a separate example.