|
|
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Reading data\n",
- "import os\n",
- "import git\n",
- "import shutil\n",
- "import tempfile\n",
- "\n",
- "# Create temporary dir\n",
- "t = tempfile.mkdtemp()\n",
- "d = 'lwc/topics/covid19/covid-model'\n",
- "# Clone into temporary dir\n",
- "git.Repo.clone_from('http://gmarx.jumpingcrab.com:8088/COVID-19/covid19-data.git', \n",
- " t, branch='master', depth=1)\n",
- "# Delete files\n",
- "#os.remove('README.txt')\n",
- "#shutil.rmtree('firstTest')\n",
- "#shutil.rmtree('secondTest')\n",
- "# Copy desired file from temporary dir\n",
- "shutil.move(os.path.join(t, 'data'), '.')\n",
- "# Remove temporary dir\n",
- "shutil.rmtree(t)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [],
- "source": [
- "import pandas as pd\n",
- "import numpy as np\n",
- "import os\n",
- "def loadData(path, file):\n",
- " csvPath=os.path.join(path, file)\n",
- " return pd.read_csv(csvPath)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>Date</th>\n",
- " <th>Country/Region</th>\n",
- " <th>Province/State</th>\n",
- " <th>Lat</th>\n",
- " <th>Long</th>\n",
- " <th>Confirmed</th>\n",
- " <th>Recovered</th>\n",
- " <th>Deaths</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>2020-01-22</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>NaN</td>\n",
- " <td>33.0</td>\n",
- " <td>65.0</td>\n",
- " <td>0</td>\n",
- " <td>0.0</td>\n",
- " <td>0</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>2020-01-23</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>NaN</td>\n",
- " <td>33.0</td>\n",
- " <td>65.0</td>\n",
- " <td>0</td>\n",
- " <td>0.0</td>\n",
- " <td>0</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>2020-01-24</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>NaN</td>\n",
- " <td>33.0</td>\n",
- " <td>65.0</td>\n",
- " <td>0</td>\n",
- " <td>0.0</td>\n",
- " <td>0</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>2020-01-25</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>NaN</td>\n",
- " <td>33.0</td>\n",
- " <td>65.0</td>\n",
- " <td>0</td>\n",
- " <td>0.0</td>\n",
- " <td>0</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>2020-01-26</td>\n",
- " <td>Afghanistan</td>\n",
- " <td>NaN</td>\n",
- " <td>33.0</td>\n",
- " <td>65.0</td>\n",
- " <td>0</td>\n",
- " <td>0.0</td>\n",
- " <td>0</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " Date Country/Region Province/State Lat Long Confirmed Recovered \\\n",
- "0 2020-01-22 Afghanistan NaN 33.0 65.0 0 0.0 \n",
- "1 2020-01-23 Afghanistan NaN 33.0 65.0 0 0.0 \n",
- "2 2020-01-24 Afghanistan NaN 33.0 65.0 0 0.0 \n",
- "3 2020-01-25 Afghanistan NaN 33.0 65.0 0 0.0 \n",
- "4 2020-01-26 Afghanistan NaN 33.0 65.0 0 0.0 \n",
- "\n",
- " Deaths \n",
- "0 0 \n",
- "1 0 \n",
- "2 0 \n",
- "3 0 \n",
- "4 0 "
- ]
- },
- "execution_count": 10,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# import jtplot submodule from jupyterthemes\n",
- "from jupyterthemes import jtplot\n",
- "PATH=os.path.join(\"data\")\n",
- "covid_data=loadData(PATH,\"time-series-19-covid-combined.csv\")\n",
- "covid_data.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 151,
- "metadata": {},
- "outputs": [],
- "source": [
- "from sklearn.model_selection import train_test_split \n",
- "train_set, test_set=train_test_split(covid_data,test_size=0.2,random_state=42)\n",
- "train_cp=train_set.copy()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "array([[<matplotlib.axes._subplots.AxesSubplot object at 0x11a434290>,\n",
- " <matplotlib.axes._subplots.AxesSubplot object at 0x1194add50>],\n",
- " [<matplotlib.axes._subplots.AxesSubplot object at 0x1194d3410>,\n",
- " <matplotlib.axes._subplots.AxesSubplot object at 0x1194f1a90>],\n",
- " [<matplotlib.axes._subplots.AxesSubplot object at 0x119516150>,\n",
- " <matplotlib.axes._subplots.AxesSubplot object at 0x1195337d0>]],\n",
- " dtype=object)"
- ]
- },
- "execution_count": 11,
- "metadata": {},
- "output_type": "execute_result"
- },
- {
- "data": {
- "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAEICAYAAAC9E5gJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3deZRdZZnv8e+PGcOQhGAZEqRAaXtFaREixOWUVgwQ7Q59G2lorgQccICrtvTSINpwBRRttRFBBjUCigyCCiIaAlKNXpshcSAMxhQQJCEQICEQQDH63D/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rTJoTKyzMhkjdR7qjK2e+l2HUbfeGqGIaPcyrQkkLQfeGxE31DBNH/CdiPhGq+Iya4Z66rc1phRHBtYckiZIulbSo5LW5v6pedjpwBuBsyWtl3R2Z6M1q42krSWdKemh3J0paes8bKakFZJOkLRa0ipJxxSm3UnSjyQ9Kel2SadJ+kXnvk35OBmMLpsB3yJdPvZS4FngbICIOAn4OXB8RGwXEcd3LEqz+pwEzAD2Bl5NulfjU4XhLwF2JF22+x7gHEkT8rBzgKfzOHNzZ0URMWo64CBgKdAPzGvRMnYFbgLuBu4CPpLLJwILgWX574RcLuCsHNMdwD6Fec3N4y8D5hbK9wWW5GnOIjfnDYhjOXBAlfLNgV8D15I2mnXArXleq4H35/G2Bi7P5bcCvYV5nJjLlwIHNrp+gfHAlcDvSO3jr2v3+hqtXTvqfLvr/2D1G7gXmF34fCCwPPfPJO38bFHYBv5ESh4vA/4KPJDr/FbAacD/q3UbaHDdtXQ7aDi+TlfmJlbSzXNl2SP/s38LTGv
- "text/plain": [
- "<Figure size 432x288 with 6 Axes>"
- ]
- },
- "metadata": {
- "needs_background": "light"
- },
- "output_type": "display_data"
- }
- ],
- "source": [
- "%matplotlib inline\n",
- "covid_data.hist()\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 153,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "(77, 8)"
- ]
- },
- "execution_count": 153,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "%matplotlib inline \n",
- "import matplotlib.pyplot as plt \n",
- "covid_mexico = covid_data[covid_data['GeoId']=='MX']\n",
- "covid_mexico.shape"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 21,
- "metadata": {},
- "outputs": [
- {
- "ename": "ImportError",
- "evalue": "The descartes package is required for plotting polygons in geopandas. You can install it using 'conda install -c conda-forge descartes' or 'pip install descartes'.",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/plotting.py\u001b[0m in \u001b[0;36mplot_polygon_collection\u001b[0;34m(ax, geoms, values, color, cmap, vmin, vmax, **kwargs)\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 81\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mdescartes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpatch\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mPolygonPatch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 82\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'descartes'",
- "\nDuring handling of the above exception, another exception occurred:\n",
- "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m<ipython-input-21-0ad2a8a84de6>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mgeopandas\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mgpd\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mworld\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_file\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'naturalearth_lowres'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mworld\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/geodataframe.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 654\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mthere\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 655\u001b[0m \"\"\"\n\u001b[0;32m--> 656\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mplot_dataframe\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 657\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 658\u001b[0m \u001b[0mplot\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mplot_dataframe\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/plotting.py\u001b[0m in \u001b[0;36mplot_dataframe\u001b[0;34m(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, classification_kwds, missing_kwds, **style_kwds)\u001b[0m\n\u001b[1;32m 545\u001b[0m \u001b[0mfigsize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfigsize\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 546\u001b[0m \u001b[0mmarkersize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmarkersize\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 547\u001b[0;31m \u001b[0;34m**\u001b[0m\u001b[0mstyle_kwds\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 548\u001b[0m )\n\u001b[1;32m 549\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/plotting.py\u001b[0m in \u001b[0;36mplot_series\u001b[0;34m(s, cmap, color, ax, figsize, **style_kwds)\u001b[0m\n\u001b[1;32m 371\u001b[0m \u001b[0mvalues_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvalues\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mpoly_idx\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcmap\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 372\u001b[0m plot_polygon_collection(\n\u001b[0;32m--> 373\u001b[0;31m \u001b[0max\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpolys\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalues_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfacecolor\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfacecolor\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcmap\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcmap\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mstyle_kwds\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 374\u001b[0m )\n\u001b[1;32m 375\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/geopandas/plotting.py\u001b[0m in \u001b[0;36mplot_polygon_collection\u001b[0;34m(ax, geoms, values, color, cmap, vmin, vmax, **kwargs)\u001b[0m\n\u001b[1;32m 82\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m raise ImportError(\n\u001b[0;32m---> 84\u001b[0;31m \u001b[0;34m\"The descartes package is required for plotting polygons in geopandas. \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 85\u001b[0m \u001b[0;34m\"You can install it using 'conda install -c conda-forge descartes' or \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 86\u001b[0m \u001b[0;34m\"'pip install descartes'.\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mImportError\u001b[0m: The descartes package is required for plotting polygons in geopandas. You can install it using 'conda install -c conda-forge descartes' or 'pip install descartes'."
- ]
- },
- {
- "data": {
- "image/png": "i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dX/PBWw7zQrba97tNCvAr53LLw0Jw8xU1VHgKECS1apanufzn4/tNO92mhW217zbaVYYzXsuvzfko8RTwO6J7V3jfRuuSbIDeDXwzLkMJGnxhoThQWBPkiuSXAwcBFbWrVkB/mR8+4+Af6uqmt2YkuZp6keJ8TmD24F7gYuAT1TVySR3AatVtQL8M/DpJGvADxnFY5qj5zH3ImynebfTrLC95t1Os8I5zhv/YZe0nlc+SmoMg6Rmy8OwnS6nHjDr+5KcSvJoki8neeMi5pyY5yXnnVj3jiSVZGFfsw2ZNck7x6/vySSfmfeM62aZ9l54Q5L7kjw8fj/ctIg5x7N8IsnTm10XlJGPjf+WR5NcM/VBq2rLfhidrPw28CbgYuAbwN51a/4M+Pj49kHgc1s503nO+nvAL41vv3tRsw6dd7zuUuB+4ASwfKHOCuwBHgZ+Zbz9ugv5tWV0Uu/d49t7ge8ucN7fBa4BHtvk/puALwEBrgMemPaYW33EsJ0up546a1XdV1U/Hm+eYHRNx6IMeW0BPsTo/678ZJ7DrTNk1tuAI1X1LEBVPT3nGScNmbeAV41vvxr43hzne/EgVfcz+jZwMweAT9XICeA1SV7/Uo+51WHY6HLqnZutqarngRcup563IbNOupVRhRdl6rzjQ8bdVfXFeQ62gSGv7ZXAlUm+muREkn1zm64bMu8HgZuTnAGOA++dz2jn5OW+t+d7SfT/F0luBpaBty16ls0keQXwUeCWBY8y1A5GHyeuZ3Qkdn+S36iq/1roVJs7BNxdVX+b5HcYXcfzlqr670UPNgtbfcSwnS6nHjIrSW4APgDsr6qfzmm2jUyb91LgLcBXknyX0WfLlQWdgBz
- "text/plain": [
- "<Figure size 432x288 with 1 Axes>"
- ]
- },
- "metadata": {
- "needs_background": "light"
- },
- "output_type": "display_data"
- }
- ],
- "source": [
- "import geopandas as gpd\n",
- "world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))\n",
- "world.plot()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "covid_data.plot(kind=\"scatter\", x=\"Long\", y=\"Lat\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 168,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>DateRep</th>\n",
- " <th>Day</th>\n",
- " <th>Month</th>\n",
- " <th>Year</th>\n",
- " <th>Cases</th>\n",
- " <th>Deaths</th>\n",
- " <th>Countries and territories</th>\n",
- " <th>GeoId</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>3985</th>\n",
- " <td>2019-12-31</td>\n",
- " <td>31</td>\n",
- " <td>12</td>\n",
- " <td>2019</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3984</th>\n",
- " <td>2020-01-01</td>\n",
- " <td>1</td>\n",
- " <td>1</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3953</th>\n",
- " <td>2020-01-02</td>\n",
- " <td>1</td>\n",
- " <td>2</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3924</th>\n",
- " <td>2020-01-03</td>\n",
- " <td>1</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3972</th>\n",
- " <td>2020-01-13</td>\n",
- " <td>13</td>\n",
- " <td>1</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>...</th>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3974</th>\n",
- " <td>2020-11-01</td>\n",
- " <td>11</td>\n",
- " <td>1</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3943</th>\n",
- " <td>2020-11-02</td>\n",
- " <td>11</td>\n",
- " <td>2</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3973</th>\n",
- " <td>2020-12-01</td>\n",
- " <td>12</td>\n",
- " <td>1</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3942</th>\n",
- " <td>2020-12-02</td>\n",
- " <td>12</td>\n",
- " <td>2</td>\n",
- " <td>2020</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3921</th>\n",
- " <td>2020-12-03</td>\n",
- " <td>12</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>4</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "<p>77 rows × 8 columns</p>\n",
- "</div>"
- ],
- "text/plain": [
- " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
- "3985 2019-12-31 31 12 2019 0 0 Mexico \n",
- "3984 2020-01-01 1 1 2020 0 0 Mexico \n",
- "3953 2020-01-02 1 2 2020 0 0 Mexico \n",
- "3924 2020-01-03 1 3 2020 2 0 Mexico \n",
- "3972 2020-01-13 13 1 2020 0 0 Mexico \n",
- "... ... ... ... ... ... ... ... \n",
- "3974 2020-11-01 11 1 2020 0 0 Mexico \n",
- "3943 2020-11-02 11 2 2020 0 0 Mexico \n",
- "3973 2020-12-01 12 1 2020 0 0 Mexico \n",
- "3942 2020-12-02 12 2 2020 0 0 Mexico \n",
- "3921 2020-12-03 12 3 2020 4 0 Mexico \n",
- "\n",
- " GeoId \n",
- "3985 MX \n",
- "3984 MX \n",
- "3953 MX \n",
- "3924 MX \n",
- "3972 MX \n",
- "... ... \n",
- "3974 MX \n",
- "3943 MX \n",
- "3973 MX \n",
- "3942 MX \n",
- "3921 MX \n",
- "\n",
- "[77 rows x 8 columns]"
- ]
- },
- "execution_count": 168,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "from datetime import datetime\n",
- "mexico['DateRep'] =pd.to_datetime(mexico.DateRep, format=\"%d/%m/%Y\")\n",
- "mexico_sort=mexico.sort_values(by='DateRep', ascending=True)\n",
- "mexico_sort"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 156,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "<matplotlib.axes._subplots.AxesSubplot at 0x13ba35150>"
- ]
- },
- "execution_count": 156,
- "metadata": {},
- "output_type": "execute_result"
- },
- {
- "data": {
- "image/png": "iVBORw0KGgoAAAANSUhEUg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Mcsk/a2kvZL2SfpU3n6RpEclPSvpHkn+rsDMrI4WOtTz34B3AN+PiIuAnwP+z2keMw28JyIuBQaB9+czfm8Dfi8i1gMTwA1nVbmZmZ2VhQb/TESMAyVJpYh4GBg61QMiM5nfLOf/AngPcF/evp1sXoCZmdXJQpdsOCypC/gmcLekg8Arp3uQpCXA48B64A+BHwCH80XeAMaAtSd57BZgC8C6desWWKadzPjkNGMTU/R1d9LT1dHocsysgU4Z/JLWA6uBq4Ep4NeB64HXAR873ZNHxHFgUNIFwFeANy20sIjYBmwDGBoa8mkez8GOPQfYOjJKuVRiplJheNMAGwdr/r41swScbqjnduDliHglIioRcSwitpOF+CcX+iL5IaAPA5cDF0ia/YXTBxw487JtocYnp9k6MsrRmQpHpo9xdKbCTSOjjE9ON7o0M2uQ0wX/6oj47vzGvK3/VA+U1Jvv6SOpE3gv8BTZL4DZlT03AzvOsGY7A2MTU5RLc9/mcqnE2MRUgyoys0Y73Rj/Bae4r/M0j10DbM/H+UvAvRFxv6QngT+X9N+B75Ct+2MF6evuZKZSmdM2U6nQ1326t8/M2tXpgn+3pF+NiD+tbpT0b8m+tD2piBgF3lqj/TngsjMt1M5OT1cHw5sGuGneGL+/4DVL1+mC/xPAVyRdz6tBP0S2QNu/LLIwWzwbB9eyYf0qH9VjZsBpgj8iXgLeKelK4C1581cj4huFV2aLqqerw4FvZsDCz8D1MNmXsmZm1uK8tLKZWWIc/GZmiXHwm5klxsFvZpYYB39ixien2bv/sJdsMEvYQlfntDbgxdrMDLzHnwwv1mZmsxz8ifBibWY2y8GfCC/WZmazHPyJmF2sbVm5xIq
- "text/plain": [
- "<Figure size 432x288 with 1 Axes>"
- ]
- },
- "metadata": {
- "needs_background": "light"
- },
- "output_type": "display_data"
- }
- ],
- "source": [
- "mexico_filter = mexico_sort[mexico_sort['Cases']!=0]\n",
- "mexico_filter.plot(kind=\"scatter\", x=\"DateRep\", y=\"Cases\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 157,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>DateRep</th>\n",
- " <th>Day</th>\n",
- " <th>Month</th>\n",
- " <th>Year</th>\n",
- " <th>Cases</th>\n",
- " <th>Deaths</th>\n",
- " <th>Countries and territories</th>\n",
- " <th>GeoId</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>3924</th>\n",
- " <td>2020-01-03</td>\n",
- " <td>1</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3923</th>\n",
- " <td>2020-02-03</td>\n",
- " <td>2</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>1</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3925</th>\n",
- " <td>2020-02-29</td>\n",
- " <td>29</td>\n",
- " <td>2</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3920</th>\n",
- " <td>2020-03-13</td>\n",
- " <td>13</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>5</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3919</th>\n",
- " <td>2020-03-14</td>\n",
- " <td>14</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>10</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3918</th>\n",
- " <td>2020-03-15</td>\n",
- " <td>15</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>15</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3917</th>\n",
- " <td>2020-03-16</td>\n",
- " <td>16</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>12</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3916</th>\n",
- " <td>2020-03-17</td>\n",
- " <td>17</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>29</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3915</th>\n",
- " <td>2020-03-18</td>\n",
- " <td>18</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>11</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3914</th>\n",
- " <td>2020-03-19</td>\n",
- " <td>19</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>25</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3913</th>\n",
- " <td>2020-03-20</td>\n",
- " <td>20</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>46</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3912</th>\n",
- " <td>2020-03-21</td>\n",
- " <td>21</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>39</td>\n",
- " <td>2</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3911</th>\n",
- " <td>2020-03-22</td>\n",
- " <td>22</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>48</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3910</th>\n",
- " <td>2020-03-23</td>\n",
- " <td>23</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>65</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3909</th>\n",
- " <td>2020-03-24</td>\n",
- " <td>24</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>51</td>\n",
- " <td>2</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3922</th>\n",
- " <td>2020-09-03</td>\n",
- " <td>9</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>2</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3921</th>\n",
- " <td>2020-12-03</td>\n",
- " <td>12</td>\n",
- " <td>3</td>\n",
- " <td>2020</td>\n",
- " <td>4</td>\n",
- " <td>0</td>\n",
- " <td>Mexico</td>\n",
- " <td>MX</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
- "3924 2020-01-03 1 3 2020 2 0 Mexico \n",
- "3923 2020-02-03 2 3 2020 1 0 Mexico \n",
- "3925 2020-02-29 29 2 2020 2 0 Mexico \n",
- "3920 2020-03-13 13 3 2020 5 0 Mexico \n",
- "3919 2020-03-14 14 3 2020 10 0 Mexico \n",
- "3918 2020-03-15 15 3 2020 15 0 Mexico \n",
- "3917 2020-03-16 16 3 2020 12 0 Mexico \n",
- "3916 2020-03-17 17 3 2020 29 0 Mexico \n",
- "3915 2020-03-18 18 3 2020 11 0 Mexico \n",
- "3914 2020-03-19 19 3 2020 25 0 Mexico \n",
- "3913 2020-03-20 20 3 2020 46 0 Mexico \n",
- "3912 2020-03-21 21 3 2020 39 2 Mexico \n",
- "3911 2020-03-22 22 3 2020 48 0 Mexico \n",
- "3910 2020-03-23 23 3 2020 65 0 Mexico \n",
- "3909 2020-03-24 24 3 2020 51 2 Mexico \n",
- "3922 2020-09-03 9 3 2020 2 0 Mexico \n",
- "3921 2020-12-03 12 3 2020 4 0 Mexico \n",
- "\n",
- " GeoId \n",
- "3924 MX \n",
- "3923 MX \n",
- "3925 MX \n",
- "3920 MX \n",
- "3919 MX \n",
- "3918 MX \n",
- "3917 MX \n",
- "3916 MX \n",
- "3915 MX \n",
- "3914 MX \n",
- "3913 MX \n",
- "3912 MX \n",
- "3911 MX \n",
- "3910 MX \n",
- "3909 MX \n",
- "3922 MX \n",
- "3921 MX "
- ]
- },
- "execution_count": 157,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "mexico_filter.head(77)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 164,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "367"
- ]
- },
- "execution_count": 164,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "sum(mexico_filter.Cases)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 163,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "3985 2019-12-31\n",
- "3954 2020-01-31\n",
- "3955 2020-01-30\n",
- "3925 2020-02-29\n",
- "3956 2020-01-29\n",
- " ... \n",
- "3952 2020-02-02\n",
- "3983 2020-02-01\n",
- "3924 2020-01-03\n",
- "3953 2020-01-02\n",
- "3984 2020-01-01\n",
- "Name: DateRep, Length: 77, dtype: datetime64[ns]"
- ]
- },
- "execution_count": 163,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "mexico.DateRep"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 160,
- "metadata": {},
- "outputs": [],
- "source": [
- "import sklearn\n",
- "# Select a linear model\n",
- "lin_reg_model = sklearn.linear_model.LinearRegression()\n",
- "# Train the model\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 161,
- "metadata": {},
- "outputs": [
- {
- "ename": "ValueError",
- "evalue": "Expected 2D array, got 1D array instead:\narray=[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.\n 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36.\n 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54.\n 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72.\n 73. 74. 75. 76. 77.].\nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m<ipython-input-161-44b24316a33b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mX\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlinspace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m77\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m77\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmexico\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mCases\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mlin_reg_model\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/sklearn/linear_model/_base.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, X, y, sample_weight)\u001b[0m\n\u001b[1;32m 490\u001b[0m \u001b[0mn_jobs_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mn_jobs\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 491\u001b[0m X, y = check_X_y(X, y, accept_sparse=['csr', 'csc', 'coo'],\n\u001b[0;32m--> 492\u001b[0;31m y_numeric=True, multi_output=True)\n\u001b[0m\u001b[1;32m 493\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 494\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0msample_weight\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/sklearn/utils/validation.py\u001b[0m in \u001b[0;36mcheck_X_y\u001b[0;34m(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)\u001b[0m\n\u001b[1;32m 753\u001b[0m \u001b[0mensure_min_features\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mensure_min_features\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 754\u001b[0m \u001b[0mwarn_on_dtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwarn_on_dtype\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 755\u001b[0;31m estimator=estimator)\n\u001b[0m\u001b[1;32m 756\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmulti_output\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 757\u001b[0m y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,\n",
- "\u001b[0;32m~/lwc/topics/covid19/covid/lib/python3.7/site-packages/sklearn/utils/validation.py\u001b[0m in \u001b[0;36mcheck_array\u001b[0;34m(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)\u001b[0m\n\u001b[1;32m 554\u001b[0m \u001b[0;34m\"Reshape your data either using array.reshape(-1, 1) if \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 555\u001b[0m \u001b[0;34m\"your data has a single feature or array.reshape(1, -1) \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 556\u001b[0;31m \"if it contains a single sample.\".format(array))\n\u001b[0m\u001b[1;32m 557\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 558\u001b[0m \u001b[0;31m# in the future np.flexible dtypes will be handled like object dtypes\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mValueError\u001b[0m: Expected 2D array, got 1D array instead:\narray=[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.\n 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36.\n 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54.\n 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72.\n 73. 74. 75. 76. 77.].\nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample."
- ]
- }
- ],
- "source": [
- "X = np.linspace(1,77,77, axis=0)\n",
- "y = mexico.Cases\n",
- "lin_reg_model.fit(X, y)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "y.shape"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.7.7"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 4
- }
|