{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "Ab4iZfp4eXPk" }, "source": [ "# Bike Rides and the Poisson Model\n", "\n", "To help the urban planners, you are called to model the daily bike rides in NYC using [this dataset](https://gist.github.com/sachinsdate/c17931a3f000492c1c42cf78bf4ce9fe/archive/7a5131d3f02575668b3c7e8c146b6a285acd2cd7.zip). The dataset contains date, day of the week, high and low temp, precipitation and bike ride counts as columns. \n", "\n" ] }, { "cell_type": "code", "source": [ "!wget https://gist.github.com/sachinsdate/c17931a3f000492c1c42cf78bf4ce9fe/archive/7a5131d3f02575668b3c7e8c146b6a285acd2cd7.zip\n", "!unzip 7a5131d3f02575668b3c7e8c146b6a285acd2cd7.zip" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "gM-y0BWye7WN", "outputId": "ba5d103a-ec03-42ec-8bf2-1094d2ed99ee" }, "execution_count": 1, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "--2023-02-26 21:10:52-- https://gist.github.com/sachinsdate/c17931a3f000492c1c42cf78bf4ce9fe/archive/7a5131d3f02575668b3c7e8c146b6a285acd2cd7.zip\n", "Resolving gist.github.com (gist.github.com)... 192.30.255.112\n", "Connecting to gist.github.com (gist.github.com)|192.30.255.112|:443... connected.\n", "HTTP request sent, awaiting response... 302 Found\n", "Location: https://codeload.github.com/gist/c17931a3f000492c1c42cf78bf4ce9fe/zip/7a5131d3f02575668b3c7e8c146b6a285acd2cd7 [following]\n", "--2023-02-26 21:10:53-- https://codeload.github.com/gist/c17931a3f000492c1c42cf78bf4ce9fe/zip/7a5131d3f02575668b3c7e8c146b6a285acd2cd7\n", "Resolving codeload.github.com (codeload.github.com)... 192.30.255.120\n", "Connecting to codeload.github.com (codeload.github.com)|192.30.255.120|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: unspecified [application/zip]\n", "Saving to: ‘7a5131d3f02575668b3c7e8c146b6a285acd2cd7.zip’\n", "\n", "7a5131d3f02575668b3 [ <=> ] 2.56K --.-KB/s in 0s \n", "\n", "2023-02-26 21:10:53 (27.7 MB/s) - ‘7a5131d3f02575668b3c7e8c146b6a285acd2cd7.zip’ saved [2623]\n", "\n", "Archive: 7a5131d3f02575668b3c7e8c146b6a285acd2cd7.zip\n", "7a5131d3f02575668b3c7e8c146b6a285acd2cd7\n", " creating: c17931a3f000492c1c42cf78bf4ce9fe-7a5131d3f02575668b3c7e8c146b6a285acd2cd7/\n", " inflating: c17931a3f000492c1c42cf78bf4ce9fe-7a5131d3f02575668b3c7e8c146b6a285acd2cd7/nyc_bb_bicyclist_counts.csv \n" ] } ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "id": "RxdI4hgDeXPr" }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "\n", "np.random.seed(0)\n", "sns.set_theme(style='whitegrid', palette='pastel')\n", "\n", "import warnings\n", "warnings.filterwarnings('ignore')" ] }, { "cell_type": "code", "source": [ "filename = \"c17931a3f000492c1c42cf78bf4ce9fe-7a5131d3f02575668b3c7e8c146b6a285acd2cd7/nyc_bb_bicyclist_counts.csv\"\n", "\n", "df = pd.read_csv(filename)\n", "df.head()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "id": "ImGoQW97gLQN", "outputId": "9e481eb5-d4f1-4d14-c8b2-d128abdab273" }, "execution_count": 3, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " Date HIGH_T LOW_T PRECIP BB_COUNT\n", "0 1-Apr-17 46.0 37.0 0.00 606\n", "1 2-Apr-17 62.1 41.0 0.00 2021\n", "2 3-Apr-17 63.0 50.0 0.03 2470\n", "3 4-Apr-17 51.1 46.0 1.18 723\n", "4 5-Apr-17 63.0 46.0 0.00 2807" ], "text/html": [ "\n", "
\n", " | Date | \n", "HIGH_T | \n", "LOW_T | \n", "PRECIP | \n", "BB_COUNT | \n", "
---|---|---|---|---|---|
0 | \n", "1-Apr-17 | \n", "46.0 | \n", "37.0 | \n", "0.00 | \n", "606 | \n", "
1 | \n", "2-Apr-17 | \n", "62.1 | \n", "41.0 | \n", "0.00 | \n", "2021 | \n", "
2 | \n", "3-Apr-17 | \n", "63.0 | \n", "50.0 | \n", "0.03 | \n", "2470 | \n", "
3 | \n", "4-Apr-17 | \n", "51.1 | \n", "46.0 | \n", "1.18 | \n", "723 | \n", "
4 | \n", "5-Apr-17 | \n", "63.0 | \n", "46.0 | \n", "0.00 | \n", "2807 | \n", "