Bike Rides and the Poisson Model#
To help the urban planners, you are called to model the daily bike rides in NYC using this dataset. The dataset contains date, day of the week, high and low temp, precipitation and bike ride couunts as columns.
Maximum Likelihood I#
The obvious choice in distributions is the Poisson distribution which depends only on one parameter, λ, which is the average number of occurrences per interval. We want to estimate this parameter using Maximum Likelihood Estimation.
Implement a Gradient Descent algorithm from scratch that will estimate the Poisson distribution according to the Maximum Likelihood criterion. Plot the estimated mean vs iterations to showcase convergence towards the true mean.
References:
This blog post and note the negative log likelihood function.
# Code here
Maximum Likelihood II#
A colleague of yours suggest that the parameter \(\lambda\) must be itself dependent on the weather and other factors since people bike when its not raining. Assume that you model \(\lambda\) as
where \(\mathbf x_i\) is one of the example features and \(\mathbf w\) is a set of parameters.
Train the model with SGD with this assumption and compare the MSE of the predictions with the Maximum Likelihood I
approach.
You may want to use this partial derivative of the log likelihood function
#