You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

955 lines
62 KiB

4 years ago
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 150,
  6. "metadata": {},
  7. "outputs": [
  8. {
  9. "data": {
  10. "text/html": [
  11. "<div>\n",
  12. "<style scoped>\n",
  13. " .dataframe tbody tr th:only-of-type {\n",
  14. " vertical-align: middle;\n",
  15. " }\n",
  16. "\n",
  17. " .dataframe tbody tr th {\n",
  18. " vertical-align: top;\n",
  19. " }\n",
  20. "\n",
  21. " .dataframe thead th {\n",
  22. " text-align: right;\n",
  23. " }\n",
  24. "</style>\n",
  25. "<table border=\"1\" class=\"dataframe\">\n",
  26. " <thead>\n",
  27. " <tr style=\"text-align: right;\">\n",
  28. " <th></th>\n",
  29. " <th>DateRep</th>\n",
  30. " <th>Day</th>\n",
  31. " <th>Month</th>\n",
  32. " <th>Year</th>\n",
  33. " <th>Cases</th>\n",
  34. " <th>Deaths</th>\n",
  35. " <th>Countries and territories</th>\n",
  36. " <th>GeoId</th>\n",
  37. " </tr>\n",
  38. " </thead>\n",
  39. " <tbody>\n",
  40. " <tr>\n",
  41. " <th>0</th>\n",
  42. " <td>24/03/2020</td>\n",
  43. " <td>24</td>\n",
  44. " <td>3</td>\n",
  45. " <td>2020</td>\n",
  46. " <td>6</td>\n",
  47. " <td>1</td>\n",
  48. " <td>Afghanistan</td>\n",
  49. " <td>AF</td>\n",
  50. " </tr>\n",
  51. " <tr>\n",
  52. " <th>1</th>\n",
  53. " <td>23/03/2020</td>\n",
  54. " <td>23</td>\n",
  55. " <td>3</td>\n",
  56. " <td>2020</td>\n",
  57. " <td>10</td>\n",
  58. " <td>0</td>\n",
  59. " <td>Afghanistan</td>\n",
  60. " <td>AF</td>\n",
  61. " </tr>\n",
  62. " <tr>\n",
  63. " <th>2</th>\n",
  64. " <td>22/03/2020</td>\n",
  65. " <td>22</td>\n",
  66. " <td>3</td>\n",
  67. " <td>2020</td>\n",
  68. " <td>0</td>\n",
  69. " <td>0</td>\n",
  70. " <td>Afghanistan</td>\n",
  71. " <td>AF</td>\n",
  72. " </tr>\n",
  73. " <tr>\n",
  74. " <th>3</th>\n",
  75. " <td>21/03/2020</td>\n",
  76. " <td>21</td>\n",
  77. " <td>3</td>\n",
  78. " <td>2020</td>\n",
  79. " <td>2</td>\n",
  80. " <td>0</td>\n",
  81. " <td>Afghanistan</td>\n",
  82. " <td>AF</td>\n",
  83. " </tr>\n",
  84. " <tr>\n",
  85. " <th>4</th>\n",
  86. " <td>20/03/2020</td>\n",
  87. " <td>20</td>\n",
  88. " <td>3</td>\n",
  89. " <td>2020</td>\n",
  90. " <td>0</td>\n",
  91. " <td>0</td>\n",
  92. " <td>Afghanistan</td>\n",
  93. " <td>AF</td>\n",
  94. " </tr>\n",
  95. " <tr>\n",
  96. " <th>...</th>\n",
  97. " <td>...</td>\n",
  98. " <td>...</td>\n",
  99. " <td>...</td>\n",
  100. " <td>...</td>\n",
  101. " <td>...</td>\n",
  102. " <td>...</td>\n",
  103. " <td>...</td>\n",
  104. " <td>...</td>\n",
  105. " </tr>\n",
  106. " <tr>\n",
  107. " <th>6546</th>\n",
  108. " <td>19/03/2020</td>\n",
  109. " <td>19</td>\n",
  110. " <td>3</td>\n",
  111. " <td>2020</td>\n",
  112. " <td>2</td>\n",
  113. " <td>0</td>\n",
  114. " <td>Zambia</td>\n",
  115. " <td>ZM</td>\n",
  116. " </tr>\n",
  117. " <tr>\n",
  118. " <th>6547</th>\n",
  119. " <td>24/03/2020</td>\n",
  120. " <td>24</td>\n",
  121. " <td>3</td>\n",
  122. " <td>2020</td>\n",
  123. " <td>0</td>\n",
  124. " <td>1</td>\n",
  125. " <td>Zimbabwe</td>\n",
  126. " <td>ZW</td>\n",
  127. " </tr>\n",
  128. " <tr>\n",
  129. " <th>6548</th>\n",
  130. " <td>23/03/2020</td>\n",
  131. " <td>23</td>\n",
  132. " <td>3</td>\n",
  133. " <td>2020</td>\n",
  134. " <td>0</td>\n",
  135. " <td>0</td>\n",
  136. " <td>Zimbabwe</td>\n",
  137. " <td>ZW</td>\n",
  138. " </tr>\n",
  139. " <tr>\n",
  140. " <th>6549</th>\n",
  141. " <td>22/03/2020</td>\n",
  142. " <td>22</td>\n",
  143. " <td>3</td>\n",
  144. " <td>2020</td>\n",
  145. " <td>1</td>\n",
  146. " <td>0</td>\n",
  147. " <td>Zimbabwe</td>\n",
  148. " <td>ZW</td>\n",
  149. " </tr>\n",
  150. " <tr>\n",
  151. " <th>6550</th>\n",
  152. " <td>21/03/2020</td>\n",
  153. " <td>21</td>\n",
  154. " <td>3</td>\n",
  155. " <td>2020</td>\n",
  156. " <td>1</td>\n",
  157. " <td>0</td>\n",
  158. " <td>Zimbabwe</td>\n",
  159. " <td>ZW</td>\n",
  160. " </tr>\n",
  161. " </tbody>\n",
  162. "</table>\n",
  163. "<p>6551 rows × 8 columns</p>\n",
  164. "</div>"
  165. ],
  166. "text/plain": [
  167. " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
  168. "0 24/03/2020 24 3 2020 6 1 Afghanistan \n",
  169. "1 23/03/2020 23 3 2020 10 0 Afghanistan \n",
  170. "2 22/03/2020 22 3 2020 0 0 Afghanistan \n",
  171. "3 21/03/2020 21 3 2020 2 0 Afghanistan \n",
  172. "4 20/03/2020 20 3 2020 0 0 Afghanistan \n",
  173. "... ... ... ... ... ... ... ... \n",
  174. "6546 19/03/2020 19 3 2020 2 0 Zambia \n",
  175. "6547 24/03/2020 24 3 2020 0 1 Zimbabwe \n",
  176. "6548 23/03/2020 23 3 2020 0 0 Zimbabwe \n",
  177. "6549 22/03/2020 22 3 2020 1 0 Zimbabwe \n",
  178. "6550 21/03/2020 21 3 2020 1 0 Zimbabwe \n",
  179. "\n",
  180. " GeoId \n",
  181. "0 AF \n",
  182. "1 AF \n",
  183. "2 AF \n",
  184. "3 AF \n",
  185. "4 AF \n",
  186. "... ... \n",
  187. "6546 ZM \n",
  188. "6547 ZW \n",
  189. "6548 ZW \n",
  190. "6549 ZW \n",
  191. "6550 ZW \n",
  192. "\n",
  193. "[6551 rows x 8 columns]"
  194. ]
  195. },
  196. "execution_count": 150,
  197. "metadata": {},
  198. "output_type": "execute_result"
  199. }
  200. ],
  201. "source": [
  202. "# Reading data\n",
  203. "import pandas as pd\n",
  204. "covid_data = pd.read_csv('https://worldhealthorg-my.sharepoint.com/personal/garnicacarrenoj_who_int/_layouts/15/Doc.aspx?sourcedoc=%7B87BD9C0A-2E91-4BE3-8308-B0B545B6DFB6%7D&file=CSV%20as%20at%2024%20March%202020-Daily%20additions.csv&action=default&mobileredirect=true&CT=1585104198257&OR=ItemsView')\n",
  205. "covid_data"
  206. ]
  207. },
  208. {
  209. "cell_type": "code",
  210. "execution_count": 151,
  211. "metadata": {},
  212. "outputs": [],
  213. "source": [
  214. "from sklearn.model_selection import train_test_split \n",
  215. "train_set, test_set=train_test_split(covid_data,test_size=0.2,random_state=42)\n",
  216. "train_cp=train_set.copy()"
  217. ]
  218. },
  219. {
  220. "cell_type": "code",
  221. "execution_count": 152,
  222. "metadata": {},
  223. "outputs": [
  224. {
  225. "data": {
  226. "text/plain": [
  227. "array([[<matplotlib.axes._subplots.AxesSubplot object at 0x13ceded90>,\n",
  228. " <matplotlib.axes._subplots.AxesSubplot object at 0x13caacad0>],\n",
  229. " [<matplotlib.axes._subplots.AxesSubplot object at 0x13cc2fd50>,\n",
  230. " <matplotlib.axes._subplots.AxesSubplot object at 0x13cc897d0>],\n",
  231. " [<matplotlib.axes._subplots.AxesSubplot object at 0x13bd9e950>,\n",
  232. " <matplotlib.axes._subplots.AxesSubplot object at 0x13bd2ea50>]],\n",
  233. " dtype=object)"
  234. ]
  235. },
  236. "execution_count": 152,
  237. "metadata": {},
  238. "output_type": "execute_result"
  239. },
  240. {
  241. "data": {
  242. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEVCAYAAAAM3jVmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB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EXgSsj4jPF8qL44ecQOqrDKlf8lxJEyRNJQ00dRPphujTJE2VtBPpZO+y5myGmZnVo55D5cOBE4G1ktbkso8D75I0g9S80w+8DyAi1klaSjpBuw04LSKeApB0OnANqcvm4ohY18RtMTOzYdTTe+cngKrMWj7EOucC51YpXz7UemZmNrY8DIOZWYk46ZuZlYiTvplZiTjpm5mViJO+mVmJOOmbmZWIk76ZWYk46ZuZlYiTvplZiTjpm5mViJO+mVmJOOmbmZWIk76ZWYk46ZuZlUjLk76k2ZJul9QnaUGr39+s1VznrZO0NOlL2gE4HzgGmE66Ecv0VsZg1kqu89ZpGrvJ7OgdAvRFxF0AkpYAc0h32RpzUxZcNaL1+hce1+RIrETaWufNBmt10p8M3Ft4fh9waHEBSfOB+fnpVkm313itScCDTY+wCn26KS/TsniboJtiheHj3b9VgVQxbJ2HmvW+qz6HDzneMVUt3iFyU8063+qkP6yIWAQsGm45SasiYmYLQmqKboq3m2KF7ou3mmr1vtu2y/GOrWbF2+oTuQPAfoXn++Yys/HKdd46SquT/s3ANElTJe0EzAWWtTiGUpEUkl7e7jhKzHW+zfwdeLaWJv2I2AacDlwDrAeWRsS6Eb7csE1AHWYRgKR+Sb+V9JikRyT9VNL7JY36s5DUK+m9ow+1O/dtJxplne/Y7aqhnmbZfklPSpo0qPznOTlPGU0ADX4Hxt3+rYciohmvY3WS1A+8NyKuk7QH8Cbgi0BvRJwyytf
  243. "text/plain": [
  244. "<Figure size 432x288 with 6 Axes>"
  245. ]
  246. },
  247. "metadata": {
  248. "needs_background": "light"
  249. },
  250. "output_type": "display_data"
  251. }
  252. ],
  253. "source": [
  254. "%matplotlib inline\n",
  255. "covid_data.hist()\n"
  256. ]
  257. },
  258. {
  259. "cell_type": "code",
  260. "execution_count": 153,
  261. "metadata": {},
  262. "outputs": [
  263. {
  264. "data": {
  265. "text/plain": [
  266. "(77, 8)"
  267. ]
  268. },
  269. "execution_count": 153,
  270. "metadata": {},
  271. "output_type": "execute_result"
  272. }
  273. ],
  274. "source": [
  275. "%matplotlib inline \n",
  276. "import matplotlib.pyplot as plt \n",
  277. "covid_mexico = covid_data[covid_data['GeoId']=='MX']\n",
  278. "covid_mexico.shape"
  279. ]
  280. },
  281. {
  282. "cell_type": "code",
  283. "execution_count": 154,
  284. "metadata": {},
  285. "outputs": [
  286. {
  287. "data": {
  288. "text/plain": [
  289. "<matplotlib.axes._subplots.AxesSubplot at 0x13d347490>"
  290. ]
  291. },
  292. "execution_count": 154,
  293. "metadata": {},
  294. "output_type": "execute_result"
  295. },
  296. {
  297. "data": {
  298. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAWmElEQVR4nO3df5Bd5X3f8fd30SJtJGwtkqrBWohIxNiDXbE4OxRHHtc2cUNtj6Cjhtp1XLWl5Y9kHJNkguR03OCm7WClk9iedFwrQCynxJhBJmIMuGEEKW0mJlmMWH45hmDLWhXQslkZLZbWK+63f9wjsyv0467uPXs5e96vGc2957n37PneWelzHz3nPM+JzESSVB893S5AkjS/DH5JqhmDX5JqxuCXpJox+CWpZhZ1u4BWrFy5MteuXdvtMiSpUh555JGXMnPV8e2VCP61a9cyPDzc7TIkqVIiYu+J2h3qkaSaMfglqWYMfkmqGYNfkmrG4JekmjH4K2p8corH9h1kfHKq26VIqphKXM6p2Xbt2c+WnSP09vQw3WiwbdN6Ng6u6XZZkirCHn/FjE9OsWXnCEemGxyaOsqR6QY37Byx5y+pZQZ/xYxOHKa3Z/avrbenh9GJw12qSFLVGPwVM9Dfx3SjMattutFgoL+vSxVJqhqDv2JWLFvMtk3rWdLbwzmLF7Gkt4dtm9azYtnibpcmqSI8uVtBGwfXsGHdSkYnDjPQ32foS5oTg7+iVixbbOBLOiMO9Uh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zpLeHcxYvYklvj2v1SJoTT+5WkGv1SGqHwV9RrtUj6Uw51CNJNWPwS1LNGPySVDMGvyTVjMEvSTVj8EtSzRj8klQzpQV/RJwfEQ9GxFMR8WR
  299. "text/plain": [
  300. "<Figure size 432x288 with 1 Axes>"
  301. ]
  302. },
  303. "metadata": {
  304. "needs_background": "light"
  305. },
  306. "output_type": "display_data"
  307. }
  308. ],
  309. "source": [
  310. "covid_mexico.plot(kind=\"scatter\", x=\"Month\", y=\"Cases\")"
  311. ]
  312. },
  313. {
  314. "cell_type": "code",
  315. "execution_count": 168,
  316. "metadata": {},
  317. "outputs": [
  318. {
  319. "data": {
  320. "text/html": [
  321. "<div>\n",
  322. "<style scoped>\n",
  323. " .dataframe tbody tr th:only-of-type {\n",
  324. " vertical-align: middle;\n",
  325. " }\n",
  326. "\n",
  327. " .dataframe tbody tr th {\n",
  328. " vertical-align: top;\n",
  329. " }\n",
  330. "\n",
  331. " .dataframe thead th {\n",
  332. " text-align: right;\n",
  333. " }\n",
  334. "</style>\n",
  335. "<table border=\"1\" class=\"dataframe\">\n",
  336. " <thead>\n",
  337. " <tr style=\"text-align: right;\">\n",
  338. " <th></th>\n",
  339. " <th>DateRep</th>\n",
  340. " <th>Day</th>\n",
  341. " <th>Month</th>\n",
  342. " <th>Year</th>\n",
  343. " <th>Cases</th>\n",
  344. " <th>Deaths</th>\n",
  345. " <th>Countries and territories</th>\n",
  346. " <th>GeoId</th>\n",
  347. " </tr>\n",
  348. " </thead>\n",
  349. " <tbody>\n",
  350. " <tr>\n",
  351. " <th>3985</th>\n",
  352. " <td>2019-12-31</td>\n",
  353. " <td>31</td>\n",
  354. " <td>12</td>\n",
  355. " <td>2019</td>\n",
  356. " <td>0</td>\n",
  357. " <td>0</td>\n",
  358. " <td>Mexico</td>\n",
  359. " <td>MX</td>\n",
  360. " </tr>\n",
  361. " <tr>\n",
  362. " <th>3984</th>\n",
  363. " <td>2020-01-01</td>\n",
  364. " <td>1</td>\n",
  365. " <td>1</td>\n",
  366. " <td>2020</td>\n",
  367. " <td>0</td>\n",
  368. " <td>0</td>\n",
  369. " <td>Mexico</td>\n",
  370. " <td>MX</td>\n",
  371. " </tr>\n",
  372. " <tr>\n",
  373. " <th>3953</th>\n",
  374. " <td>2020-01-02</td>\n",
  375. " <td>1</td>\n",
  376. " <td>2</td>\n",
  377. " <td>2020</td>\n",
  378. " <td>0</td>\n",
  379. " <td>0</td>\n",
  380. " <td>Mexico</td>\n",
  381. " <td>MX</td>\n",
  382. " </tr>\n",
  383. " <tr>\n",
  384. " <th>3924</th>\n",
  385. " <td>2020-01-03</td>\n",
  386. " <td>1</td>\n",
  387. " <td>3</td>\n",
  388. " <td>2020</td>\n",
  389. " <td>2</td>\n",
  390. " <td>0</td>\n",
  391. " <td>Mexico</td>\n",
  392. " <td>MX</td>\n",
  393. " </tr>\n",
  394. " <tr>\n",
  395. " <th>3972</th>\n",
  396. " <td>2020-01-13</td>\n",
  397. " <td>13</td>\n",
  398. " <td>1</td>\n",
  399. " <td>2020</td>\n",
  400. " <td>0</td>\n",
  401. " <td>0</td>\n",
  402. " <td>Mexico</td>\n",
  403. " <td>MX</td>\n",
  404. " </tr>\n",
  405. " <tr>\n",
  406. " <th>...</th>\n",
  407. " <td>...</td>\n",
  408. " <td>...</td>\n",
  409. " <td>...</td>\n",
  410. " <td>...</td>\n",
  411. " <td>...</td>\n",
  412. " <td>...</td>\n",
  413. " <td>...</td>\n",
  414. " <td>...</td>\n",
  415. " </tr>\n",
  416. " <tr>\n",
  417. " <th>3974</th>\n",
  418. " <td>2020-11-01</td>\n",
  419. " <td>11</td>\n",
  420. " <td>1</td>\n",
  421. " <td>2020</td>\n",
  422. " <td>0</td>\n",
  423. " <td>0</td>\n",
  424. " <td>Mexico</td>\n",
  425. " <td>MX</td>\n",
  426. " </tr>\n",
  427. " <tr>\n",
  428. " <th>3943</th>\n",
  429. " <td>2020-11-02</td>\n",
  430. " <td>11</td>\n",
  431. " <td>2</td>\n",
  432. " <td>2020</td>\n",
  433. " <td>0</td>\n",
  434. " <td>0</td>\n",
  435. " <td>Mexico</td>\n",
  436. " <td>MX</td>\n",
  437. " </tr>\n",
  438. " <tr>\n",
  439. " <th>3973</th>\n",
  440. " <td>2020-12-01</td>\n",
  441. " <td>12</td>\n",
  442. " <td>1</td>\n",
  443. " <td>2020</td>\n",
  444. " <td>0</td>\n",
  445. " <td>0</td>\n",
  446. " <td>Mexico</td>\n",
  447. " <td>MX</td>\n",
  448. " </tr>\n",
  449. " <tr>\n",
  450. " <th>3942</th>\n",
  451. " <td>2020-12-02</td>\n",
  452. " <td>12</td>\n",
  453. " <td>2</td>\n",
  454. " <td>2020</td>\n",
  455. " <td>0</td>\n",
  456. " <td>0</td>\n",
  457. " <td>Mexico</td>\n",
  458. " <td>MX</td>\n",
  459. " </tr>\n",
  460. " <tr>\n",
  461. " <th>3921</th>\n",
  462. " <td>2020-12-03</td>\n",
  463. " <td>12</td>\n",
  464. " <td>3</td>\n",
  465. " <td>2020</td>\n",
  466. " <td>4</td>\n",
  467. " <td>0</td>\n",
  468. " <td>Mexico</td>\n",
  469. " <td>MX</td>\n",
  470. " </tr>\n",
  471. " </tbody>\n",
  472. "</table>\n",
  473. "<p>77 rows × 8 columns</p>\n",
  474. "</div>"
  475. ],
  476. "text/plain": [
  477. " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
  478. "3985 2019-12-31 31 12 2019 0 0 Mexico \n",
  479. "3984 2020-01-01 1 1 2020 0 0 Mexico \n",
  480. "3953 2020-01-02 1 2 2020 0 0 Mexico \n",
  481. "3924 2020-01-03 1 3 2020 2 0 Mexico \n",
  482. "3972 2020-01-13 13 1 2020 0 0 Mexico \n",
  483. "... ... ... ... ... ... ... ... \n",
  484. "3974 2020-11-01 11 1 2020 0 0 Mexico \n",
  485. "3943 2020-11-02 11 2 2020 0 0 Mexico \n",
  486. "3973 2020-12-01 12 1 2020 0 0 Mexico \n",
  487. "3942 2020-12-02 12 2 2020 0 0 Mexico \n",
  488. "3921 2020-12-03 12 3 2020 4 0 Mexico \n",
  489. "\n",
  490. " GeoId \n",
  491. "3985 MX \n",
  492. "3984 MX \n",
  493. "3953 MX \n",
  494. "3924 MX \n",
  495. "3972 MX \n",
  496. "... ... \n",
  497. "3974 MX \n",
  498. "3943 MX \n",
  499. "3973 MX \n",
  500. "3942 MX \n",
  501. "3921 MX \n",
  502. "\n",
  503. "[77 rows x 8 columns]"
  504. ]
  505. },
  506. "execution_count": 168,
  507. "metadata": {},
  508. "output_type": "execute_result"
  509. }
  510. ],
  511. "source": [
  512. "from datetime import datetime\n",
  513. "mexico['DateRep'] =pd.to_datetime(mexico.DateRep, format=\"%d/%m/%Y\")\n",
  514. "mexico_sort=mexico.sort_values(by='DateRep', ascending=True)\n",
  515. "mexico_sort"
  516. ]
  517. },
  518. {
  519. "cell_type": "code",
  520. "execution_count": null,
  521. "metadata": {},
  522. "outputs": [],
  523. "source": []
  524. },
  525. {
  526. "cell_type": "code",
  527. "execution_count": 156,
  528. "metadata": {},
  529. "outputs": [
  530. {
  531. "data": {
  532. "text/plain": [
  533. "<matplotlib.axes._subplots.AxesSubplot at 0x13ba35150>"
  534. ]
  535. },
  536. "execution_count": 156,
  537. "metadata": {},
  538. "output_type": "execute_result"
  539. },
  540. {
  541. "data": {
  542. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAX1UlEQVR4nO3df5Dc9X3f8edrpeV01QlzOh0aVWf5iIXtYvc4uxdsLOoaE8c/kgg6csEu42oSGrWZ4tpJWgTtZGJPmxk4zyTg/ETBjuUOdmA4u1KwDaEyxKkzJQhbOiMwBmNTnQJIvp6MjpzOJ+27f3y/F/ZOK+kk3Xd/fV6PGc3ufva7u++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SwitpOF+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
  543. "text/plain": [
  544. "<Figure size 432x288 with 1 Axes>"
  545. ]
  546. },
  547. "metadata": {
  548. "needs_background": "light"
  549. },
  550. "output_type": "display_data"
  551. }
  552. ],
  553. "source": [
  554. "mexico_filter = mexico_sort[mexico_sort['Cases']!=0]\n",
  555. "mexico_filter.plot(kind=\"scatter\", x=\"DateRep\", y=\"Cases\")"
  556. ]
  557. },
  558. {
  559. "cell_type": "code",
  560. "execution_count": 157,
  561. "metadata": {},
  562. "outputs": [
  563. {
  564. "data": {
  565. "text/html": [
  566. "<div>\n",
  567. "<style scoped>\n",
  568. " .dataframe tbody tr th:only-of-type {\n",
  569. " vertical-align: middle;\n",
  570. " }\n",
  571. "\n",
  572. " .dataframe tbody tr th {\n",
  573. " vertical-align: top;\n",
  574. " }\n",
  575. "\n",
  576. " .dataframe thead th {\n",
  577. " text-align: right;\n",
  578. " }\n",
  579. "</style>\n",
  580. "<table border=\"1\" class=\"dataframe\">\n",
  581. " <thead>\n",
  582. " <tr style=\"text-align: right;\">\n",
  583. " <th></th>\n",
  584. " <th>DateRep</th>\n",
  585. " <th>Day</th>\n",
  586. " <th>Month</th>\n",
  587. " <th>Year</th>\n",
  588. " <th>Cases</th>\n",
  589. " <th>Deaths</th>\n",
  590. " <th>Countries and territories</th>\n",
  591. " <th>GeoId</th>\n",
  592. " </tr>\n",
  593. " </thead>\n",
  594. " <tbody>\n",
  595. " <tr>\n",
  596. " <th>3924</th>\n",
  597. " <td>2020-01-03</td>\n",
  598. " <td>1</td>\n",
  599. " <td>3</td>\n",
  600. " <td>2020</td>\n",
  601. " <td>2</td>\n",
  602. " <td>0</td>\n",
  603. " <td>Mexico</td>\n",
  604. " <td>MX</td>\n",
  605. " </tr>\n",
  606. " <tr>\n",
  607. " <th>3923</th>\n",
  608. " <td>2020-02-03</td>\n",
  609. " <td>2</td>\n",
  610. " <td>3</td>\n",
  611. " <td>2020</td>\n",
  612. " <td>1</td>\n",
  613. " <td>0</td>\n",
  614. " <td>Mexico</td>\n",
  615. " <td>MX</td>\n",
  616. " </tr>\n",
  617. " <tr>\n",
  618. " <th>3925</th>\n",
  619. " <td>2020-02-29</td>\n",
  620. " <td>29</td>\n",
  621. " <td>2</td>\n",
  622. " <td>2020</td>\n",
  623. " <td>2</td>\n",
  624. " <td>0</td>\n",
  625. " <td>Mexico</td>\n",
  626. " <td>MX</td>\n",
  627. " </tr>\n",
  628. " <tr>\n",
  629. " <th>3920</th>\n",
  630. " <td>2020-03-13</td>\n",
  631. " <td>13</td>\n",
  632. " <td>3</td>\n",
  633. " <td>2020</td>\n",
  634. " <td>5</td>\n",
  635. " <td>0</td>\n",
  636. " <td>Mexico</td>\n",
  637. " <td>MX</td>\n",
  638. " </tr>\n",
  639. " <tr>\n",
  640. " <th>3919</th>\n",
  641. " <td>2020-03-14</td>\n",
  642. " <td>14</td>\n",
  643. " <td>3</td>\n",
  644. " <td>2020</td>\n",
  645. " <td>10</td>\n",
  646. " <td>0</td>\n",
  647. " <td>Mexico</td>\n",
  648. " <td>MX</td>\n",
  649. " </tr>\n",
  650. " <tr>\n",
  651. " <th>3918</th>\n",
  652. " <td>2020-03-15</td>\n",
  653. " <td>15</td>\n",
  654. " <td>3</td>\n",
  655. " <td>2020</td>\n",
  656. " <td>15</td>\n",
  657. " <td>0</td>\n",
  658. " <td>Mexico</td>\n",
  659. " <td>MX</td>\n",
  660. " </tr>\n",
  661. " <tr>\n",
  662. " <th>3917</th>\n",
  663. " <td>2020-03-16</td>\n",
  664. " <td>16</td>\n",
  665. " <td>3</td>\n",
  666. " <td>2020</td>\n",
  667. " <td>12</td>\n",
  668. " <td>0</td>\n",
  669. " <td>Mexico</td>\n",
  670. " <td>MX</td>\n",
  671. " </tr>\n",
  672. " <tr>\n",
  673. " <th>3916</th>\n",
  674. " <td>2020-03-17</td>\n",
  675. " <td>17</td>\n",
  676. " <td>3</td>\n",
  677. " <td>2020</td>\n",
  678. " <td>29</td>\n",
  679. " <td>0</td>\n",
  680. " <td>Mexico</td>\n",
  681. " <td>MX</td>\n",
  682. " </tr>\n",
  683. " <tr>\n",
  684. " <th>3915</th>\n",
  685. " <td>2020-03-18</td>\n",
  686. " <td>18</td>\n",
  687. " <td>3</td>\n",
  688. " <td>2020</td>\n",
  689. " <td>11</td>\n",
  690. " <td>0</td>\n",
  691. " <td>Mexico</td>\n",
  692. " <td>MX</td>\n",
  693. " </tr>\n",
  694. " <tr>\n",
  695. " <th>3914</th>\n",
  696. " <td>2020-03-19</td>\n",
  697. " <td>19</td>\n",
  698. " <td>3</td>\n",
  699. " <td>2020</td>\n",
  700. " <td>25</td>\n",
  701. " <td>0</td>\n",
  702. " <td>Mexico</td>\n",
  703. " <td>MX</td>\n",
  704. " </tr>\n",
  705. " <tr>\n",
  706. " <th>3913</th>\n",
  707. " <td>2020-03-20</td>\n",
  708. " <td>20</td>\n",
  709. " <td>3</td>\n",
  710. " <td>2020</td>\n",
  711. " <td>46</td>\n",
  712. " <td>0</td>\n",
  713. " <td>Mexico</td>\n",
  714. " <td>MX</td>\n",
  715. " </tr>\n",
  716. " <tr>\n",
  717. " <th>3912</th>\n",
  718. " <td>2020-03-21</td>\n",
  719. " <td>21</td>\n",
  720. " <td>3</td>\n",
  721. " <td>2020</td>\n",
  722. " <td>39</td>\n",
  723. " <td>2</td>\n",
  724. " <td>Mexico</td>\n",
  725. " <td>MX</td>\n",
  726. " </tr>\n",
  727. " <tr>\n",
  728. " <th>3911</th>\n",
  729. " <td>2020-03-22</td>\n",
  730. " <td>22</td>\n",
  731. " <td>3</td>\n",
  732. " <td>2020</td>\n",
  733. " <td>48</td>\n",
  734. " <td>0</td>\n",
  735. " <td>Mexico</td>\n",
  736. " <td>MX</td>\n",
  737. " </tr>\n",
  738. " <tr>\n",
  739. " <th>3910</th>\n",
  740. " <td>2020-03-23</td>\n",
  741. " <td>23</td>\n",
  742. " <td>3</td>\n",
  743. " <td>2020</td>\n",
  744. " <td>65</td>\n",
  745. " <td>0</td>\n",
  746. " <td>Mexico</td>\n",
  747. " <td>MX</td>\n",
  748. " </tr>\n",
  749. " <tr>\n",
  750. " <th>3909</th>\n",
  751. " <td>2020-03-24</td>\n",
  752. " <td>24</td>\n",
  753. " <td>3</td>\n",
  754. " <td>2020</td>\n",
  755. " <td>51</td>\n",
  756. " <td>2</td>\n",
  757. " <td>Mexico</td>\n",
  758. " <td>MX</td>\n",
  759. " </tr>\n",
  760. " <tr>\n",
  761. " <th>3922</th>\n",
  762. " <td>2020-09-03</td>\n",
  763. " <td>9</td>\n",
  764. " <td>3</td>\n",
  765. " <td>2020</td>\n",
  766. " <td>2</td>\n",
  767. " <td>0</td>\n",
  768. " <td>Mexico</td>\n",
  769. " <td>MX</td>\n",
  770. " </tr>\n",
  771. " <tr>\n",
  772. " <th>3921</th>\n",
  773. " <td>2020-12-03</td>\n",
  774. " <td>12</td>\n",
  775. " <td>3</td>\n",
  776. " <td>2020</td>\n",
  777. " <td>4</td>\n",
  778. " <td>0</td>\n",
  779. " <td>Mexico</td>\n",
  780. " <td>MX</td>\n",
  781. " </tr>\n",
  782. " </tbody>\n",
  783. "</table>\n",
  784. "</div>"
  785. ],
  786. "text/plain": [
  787. " DateRep Day Month Year Cases Deaths Countries and territories \\\n",
  788. "3924 2020-01-03 1 3 2020 2 0 Mexico \n",
  789. "3923 2020-02-03 2 3 2020 1 0 Mexico \n",
  790. "3925 2020-02-29 29 2 2020 2 0 Mexico \n",
  791. "3920 2020-03-13 13 3 2020 5 0 Mexico \n",
  792. "3919 2020-03-14 14 3 2020 10 0 Mexico \n",
  793. "3918 2020-03-15 15 3 2020 15 0 Mexico \n",
  794. "3917 2020-03-16 16 3 2020 12 0 Mexico \n",
  795. "3916 2020-03-17 17 3 2020 29 0 Mexico \n",
  796. "3915 2020-03-18 18 3 2020 11 0 Mexico \n",
  797. "3914 2020-03-19 19 3 2020 25 0 Mexico \n",
  798. "3913 2020-03-20 20 3 2020 46 0 Mexico \n",
  799. "3912 2020-03-21 21 3 2020 39 2 Mexico \n",
  800. "3911 2020-03-22 22 3 2020 48 0 Mexico \n",
  801. "3910 2020-03-23 23 3 2020 65 0 Mexico \n",
  802. "3909 2020-03-24 24 3 2020 51 2 Mexico \n",
  803. "3922 2020-09-03 9 3 2020 2 0 Mexico \n",
  804. "3921 2020-12-03 12 3 2020 4 0 Mexico \n",
  805. "\n",
  806. " GeoId \n",
  807. "3924 MX \n",
  808. "3923 MX \n",
  809. "3925 MX \n",
  810. "3920 MX \n",
  811. "3919 MX \n",
  812. "3918 MX \n",
  813. "3917 MX \n",
  814. "3916 MX \n",
  815. "3915 MX \n",
  816. "3914 MX \n",
  817. "3913 MX \n",
  818. "3912 MX \n",
  819. "3911 MX \n",
  820. "3910 MX \n",
  821. "3909 MX \n",
  822. "3922 MX \n",
  823. "3921 MX "
  824. ]
  825. },
  826. "execution_count": 157,
  827. "metadata": {},
  828. "output_type": "execute_result"
  829. }
  830. ],
  831. "source": [
  832. "mexico_filter.head(77)"
  833. ]
  834. },
  835. {
  836. "cell_type": "code",
  837. "execution_count": 164,
  838. "metadata": {},
  839. "outputs": [
  840. {
  841. "data": {
  842. "text/plain": [
  843. "367"
  844. ]
  845. },
  846. "execution_count": 164,
  847. "metadata": {},
  848. "output_type": "execute_result"
  849. }
  850. ],
  851. "source": [
  852. "sum(mexico_filter.Cases)"
  853. ]
  854. },
  855. {
  856. "cell_type": "code",
  857. "execution_count": 163,
  858. "metadata": {},
  859. "outputs": [
  860. {
  861. "data": {
  862. "text/plain": [
  863. "3985 2019-12-31\n",
  864. "3954 2020-01-31\n",
  865. "3955 2020-01-30\n",
  866. "3925 2020-02-29\n",
  867. "3956 2020-01-29\n",
  868. " ... \n",
  869. "3952 2020-02-02\n",
  870. "3983 2020-02-01\n",
  871. "3924 2020-01-03\n",
  872. "3953 2020-01-02\n",
  873. "3984 2020-01-01\n",
  874. "Name: DateRep, Length: 77, dtype: datetime64[ns]"
  875. ]
  876. },
  877. "execution_count": 163,
  878. "metadata": {},
  879. "output_type": "execute_result"
  880. }
  881. ],
  882. "source": [
  883. "mexico.DateRep"
  884. ]
  885. },
  886. {
  887. "cell_type": "code",
  888. "execution_count": 160,
  889. "metadata": {},
  890. "outputs": [],
  891. "source": [
  892. "import sklearn\n",
  893. "# Select a linear model\n",
  894. "lin_reg_model = sklearn.linear_model.LinearRegression()\n",
  895. "# Train the model\n"
  896. ]
  897. },
  898. {
  899. "cell_type": "code",
  900. "execution_count": 161,
  901. "metadata": {},
  902. "outputs": [
  903. {
  904. "ename": "ValueError",
  905. "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.",
  906. "output_type": "error",
  907. "traceback": [
  908. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  909. "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
  910. "\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",
  911. "\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",
  912. "\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",
  913. "\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",
  914. "\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."
  915. ]
  916. }
  917. ],
  918. "source": [
  919. "X = np.linspace(1,77,77, axis=0)\n",
  920. "y = mexico.Cases\n",
  921. "lin_reg_model.fit(X, y)"
  922. ]
  923. },
  924. {
  925. "cell_type": "code",
  926. "execution_count": null,
  927. "metadata": {},
  928. "outputs": [],
  929. "source": [
  930. "y.shape"
  931. ]
  932. }
  933. ],
  934. "metadata": {
  935. "kernelspec": {
  936. "display_name": "Python 3",
  937. "language": "python",
  938. "name": "python3"
  939. },
  940. "language_info": {
  941. "codemirror_mode": {
  942. "name": "ipython",
  943. "version": 3
  944. },
  945. "file_extension": ".py",
  946. "mimetype": "text/x-python",
  947. "name": "python",
  948. "nbconvert_exporter": "python",
  949. "pygments_lexer": "ipython3",
  950. "version": "3.7.7"
  951. }
  952. },
  953. "nbformat": 4,
  954. "nbformat_minor": 4
  955. }