Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jwagner31 committed Dec 13, 2023
1 parent 3a08342 commit f9d6cee
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion notebooks/FinalMilestone.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118598,7 +118598,7 @@
"id": "30df508c",
"metadata": {},
"source": [
"First, we fit the GAM to the hot data after splitting the data into a train and test set. We use a Poisson distribution, and perform a gridsearch over **lam**, the smoothing parameter, and **n_splines**, the number of splines to use. We predict the number of violent incidents within each gridbox on a given day based on the temperature. The summary statistics are slightly harder to interpret than your standard sklearn model, but the most important number we looked for was the Psuedo R-Squared which told us how well our model explained the variance within the data. "
"First, we fit the GAM to the hot data after splitting the data into a train and test set (takes about 2 minutes total). We use a Poisson distribution, and perform a gridsearch over **lam**, the smoothing parameter, and **n_splines**, the number of splines to use. We predict the number of violent incidents within each gridbox on a given day based on the temperature. The summary statistics are slightly harder to interpret than your standard sklearn model, but the most important number we looked for was the Psuedo R-Squared which told us how well our model explained the variance within the data. For the days where the temperature was greater than 90 degrees, we were able to explain around 60% of the variance which is in line with other studies. Of note is the effective degrees of freedom (DoF), which is quite high at about 38. This suggests our model might be slightly biased. Unlike a regression model, the p-values for each spline do not really mean anything for this model so they are not of interest to us."
]
},
{
Expand Down Expand Up @@ -118668,6 +118668,14 @@
"print(hotgam.summary())"
]
},
{
"cell_type": "markdown",
"id": "fb769a60",
"metadata": {},
"source": [
"Now let's do some predictions on the test set for the hot data. The mean absolute percentage error is 0.471, which we will explain below after we predict on the cold data."
]
},
{
"cell_type": "code",
"execution_count": 234,
Expand Down Expand Up @@ -118698,6 +118706,14 @@
"print(mape)\n"
]
},
{
"cell_type": "markdown",
"id": "7baeec6a",
"metadata": {},
"source": [
"Now, we follow an identical process for fitting the model to days where the temperature was less than 90 degrees Fahrenheit. This model takes longer to fit, up to 9 minutes. The psuedo R-squared is 0.5389, which is not far off the above model, and indicates a good fit on the data. "
]
},
{
"cell_type": "code",
"execution_count": 235,
Expand Down

0 comments on commit f9d6cee

Please sign in to comment.