diff --git a/README.md b/README.md index dbdfe31..0208660 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ This is a predictive model that works with population, governmental transfers, a This project is written in **Python** and uses the following Python libraries installed: * [Pandas](https://pandas.pydata.org/) -* [Numpy](https://numpy.org/) * [matplotlib](https://matplotlib.org/) * [Seaborn](https://seaborn.pydata.org/) * [SciPy Stats](https://docs.scipy.org/doc/scipy/tutorial/stats.html) @@ -51,7 +50,6 @@ The user might run into issues installing `sklearn`, this can be resolved by usi * Line 9 * Markdown and README - Throughout kentucky_pov_ml.ipynb look to the markdown notes for further information on the code presented. ### Further work to be done: diff --git a/kentucky_povrate_ml.ipynb b/kentucky_povrate_ml.ipynb index 2f9740c..11a2ddd 100644 --- a/kentucky_povrate_ml.ipynb +++ b/kentucky_povrate_ml.ipynb @@ -23,7 +23,6 @@ "outputs": [], "source": [ "import pandas as pd\n", - "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "from scipy.stats import pearsonr , spearmanr\n", @@ -526,319 +525,319 @@ " \n", " \n", " \n", - " 1253\n", - " Carter County, KY\n", + " 1321\n", + " Montgomery County, KY\n", " 21\n", - " 20.000000\n", - " 7.161154\n", - " 11.964175\n", - " 2.948242\n", - " 0.194275\n", - " 26797\n", - " 2.968643\n", - " 8.3\n", + " 23.500000\n", + " 15.881035\n", + " 8.173329\n", + " 2.017834\n", + " 0.135927\n", + " 26860\n", + " 1.176897\n", + " 8.8\n", + " 2012-01-01\n", + " True\n", + " \n", + " \n", + " 656\n", + " Graves County, KY\n", + " 21\n", + " 17.900000\n", + " 12.426165\n", + " 11.247675\n", + " 2.984805\n", + " 0.188483\n", + " 37266\n", + " 2.738310\n", + " 4.6\n", " 2019-01-01\n", " False\n", " \n", " \n", - " 997\n", - " Barren County, KY\n", + " 9\n", + " Jefferson County, KY\n", " 21\n", - " 17.800000\n", - " 15.843979\n", - " 7.495861\n", - " 1.960841\n", - " 0.150525\n", - " 41435\n", - " 1.426209\n", - " 5.2\n", - " 2007-01-01\n", + " 14.200000\n", + " 35.990448\n", + " 9.287062\n", + " 2.294696\n", + " 0.166599\n", + " 766757\n", + " 1.991303\n", + " 4.0\n", + " 2019-01-01\n", " False\n", " \n", " \n", - " 933\n", - " Hardin County, KY\n", + " 920\n", + " Grayson County, KY\n", " 21\n", - " 13.000000\n", - " 23.804953\n", - " 6.014126\n", - " 1.071944\n", - " 0.103278\n", - " 95015\n", - " 1.078955\n", - " 5.4\n", + " 17.900000\n", + " 11.018719\n", + " 6.995480\n", + " 1.463927\n", + " 0.138491\n", + " 24962\n", + " 1.469075\n", + " 7.1\n", " 2004-01-01\n", " False\n", " \n", " \n", - " 713\n", - " Calloway County, KY\n", + " 1815\n", + " Owsley County, KY\n", " 21\n", - " 20.430784\n", - " 15.422836\n", - " 6.061980\n", - " 1.311061\n", - " 0.146178\n", - " 34499\n", - " 0.888641\n", - " 7.1\n", - " 2002-01-01\n", - " False\n", + " 45.100000\n", + " 4.359246\n", + " 16.919987\n", + " 2.861929\n", + " 0.177699\n", + " 4502\n", + " 7.470229\n", + " 10.4\n", + " 2014-01-01\n", + " True\n", " \n", " \n", - " 357\n", - " Franklin County, KY\n", + " 451\n", + " Grant County, KY\n", " 21\n", - " 15.200000\n", - " 28.217741\n", - " 9.739244\n", - " 2.831964\n", - " 0.142133\n", - " 49313\n", - " 1.060611\n", - " 7.9\n", - " 2011-01-01\n", + " 15.600000\n", + " 7.902816\n", + " 6.414626\n", + " 1.581160\n", + " 0.100228\n", + " 24544\n", + " 1.058049\n", + " 5.5\n", + " 2007-01-01\n", " False\n", " \n", " \n", - " 962\n", - " Monroe County, KY\n", + " 447\n", + " Kenton County, KY\n", " 21\n", - " 23.500000\n", - " 8.739933\n", - " 10.445418\n", - " 3.007630\n", - " 0.169882\n", - " 10990\n", - " 2.249311\n", - " 8.3\n", - " 2008-01-01\n", - " True\n", + " 11.300000\n", + " 18.808552\n", + " 5.450023\n", + " 1.184374\n", + " 0.110031\n", + " 153138\n", + " 0.916748\n", + " 4.6\n", + " 2004-01-01\n", + " False\n", " \n", " \n", - " 223\n", - " Fayette County, KY\n", + " 743\n", + " Marshall County, KY\n", " 21\n", - " 17.400000\n", - " 29.270203\n", - " 6.720423\n", - " 1.350066\n", - " 0.104949\n", - " 292514\n", - " 0.955715\n", - " 7.8\n", - " 2009-01-01\n", + " 13.700000\n", + " 16.654171\n", + " 9.731167\n", + " 2.692509\n", + " 0.200218\n", + " 31261\n", + " 1.120017\n", + " 8.1\n", + " 2012-01-01\n", " False\n", " \n", " \n", - " 1017\n", - " Barren County, KY\n", + " 1809\n", + " Clark County, KY\n", " 21\n", - " 19.700000\n", - " 13.961295\n", - " 8.977512\n", - " 2.171124\n", - " 0.152546\n", - " 42171\n", - " 1.621197\n", - " 12.3\n", - " 2009-01-01\n", + " 20.430784\n", + " 17.591070\n", + " 5.768903\n", + " 1.144135\n", + " 0.125872\n", + " 33407\n", + " 1.079571\n", + " 5.6\n", + " 2002-01-01\n", " False\n", " \n", " \n", - " 1699\n", - " Lewis County, KY\n", + " 1434\n", + " Hopkins County, KY\n", " 21\n", - " 28.200000\n", - " 4.818586\n", - " 9.594358\n", - " 2.015576\n", - " 0.146101\n", - " 13915\n", - " 2.106990\n", - " 15.2\n", - " 2009-01-01\n", - " True\n", + " 18.500000\n", + " 16.228664\n", + " 8.579361\n", + " 1.992881\n", + " 0.150943\n", + " 47051\n", + " 1.311985\n", + " 7.3\n", + " 2008-01-01\n", + " False\n", " \n", " \n", - " 1869\n", - " Bell County, KY\n", + " 1660\n", + " Clay County, KY\n", " 21\n", - " 25.900000\n", - " 11.446885\n", - " 9.538232\n", - " 1.971129\n", - " 0.139935\n", - " 29478\n", - " 2.259345\n", - " 8.6\n", - " 2003-01-01\n", + " 42.800000\n", + " 7.114488\n", + " 12.574217\n", + " 2.805054\n", + " 0.131124\n", + " 21186\n", + " 3.442334\n", + " 14.3\n", + " 2013-01-01\n", " True\n", " \n", " \n", - " 1521\n", + " 1510\n", " Union County, KY\n", " 21\n", - " 16.300000\n", - " 15.410182\n", - " 10.961823\n", - " 2.686237\n", - " 0.167024\n", - " 14471\n", - " 2.701217\n", - " 5.0\n", - " 2018-01-01\n", + " 19.400000\n", + " 17.732498\n", + " 9.080130\n", + " 2.095810\n", + " 0.134328\n", + " 15276\n", + " 1.654108\n", + " 9.7\n", + " 2010-01-01\n", " False\n", " \n", " \n", - " 1743\n", - " Lewis County, KY\n", + " 1064\n", + " Boyle County, KY\n", " 21\n", - " 23.200000\n", - " 5.170169\n", - " 11.474494\n", - " 2.794649\n", - " 0.185085\n", - " 13275\n", - " 3.279235\n", - " 8.9\n", + " 15.500000\n", + " 20.321545\n", + " 9.870158\n", + " 2.673707\n", + " 0.196008\n", + " 30060\n", + " 1.772534\n", + " 4.7\n", " 2019-01-01\n", - " True\n", + " False\n", " \n", " \n", - " 535\n", - " Todd County, KY\n", + " 1961\n", + " Adair County, KY\n", " 21\n", - " 22.000000\n", - " 6.583954\n", - " 8.336391\n", - " 2.176189\n", - " 0.144673\n", - " 12428\n", - " 1.402092\n", - " 8.7\n", - " 2011-01-01\n", + " 27.200000\n", + " 8.379422\n", + " 11.054665\n", + " 2.398944\n", + " 0.173625\n", + " 19162\n", + " 3.568906\n", + " 7.2\n", + " 2015-01-01\n", " True\n", " \n", " \n", - " 944\n", - " Grayson County, KY\n", + " 1756\n", + " Breathitt County, KY\n", " 21\n", - " 19.700000\n", - " 10.139429\n", - " 7.809289\n", - " 1.998294\n", - " 0.146518\n", - " 25444\n", - " 1.421122\n", - " 8.1\n", - " 2007-01-01\n", - " False\n", - " \n", - " \n", - " 358\n", - " Anderson County, KY\n", - " 21\n", - " 11.400000\n", - " 7.722777\n", - " 7.308096\n", - " 1.899991\n", - " 0.136663\n", - " 21747\n", - " 0.715417\n", - " 6.4\n", - " 2013-01-01\n", - " False\n", + " 33.000000\n", + " 8.735394\n", + " 16.249968\n", + " 2.886312\n", + " 0.149858\n", + " 13366\n", + " 5.836183\n", + " 11.4\n", + " 2014-01-01\n", + " True\n", " \n", " \n", "\n", "" ], "text/plain": [ - " County State Poverty Rate Wages and Salary per Capita \\\n", - "1253 Carter County, KY 21 20.000000 7.161154 \n", - "997 Barren County, KY 21 17.800000 15.843979 \n", - "933 Hardin County, KY 21 13.000000 23.804953 \n", - "713 Calloway County, KY 21 20.430784 15.422836 \n", - "357 Franklin County, KY 21 15.200000 28.217741 \n", - "962 Monroe County, KY 21 23.500000 8.739933 \n", - "223 Fayette County, KY 21 17.400000 29.270203 \n", - "1017 Barren County, KY 21 19.700000 13.961295 \n", - "1699 Lewis County, KY 21 28.200000 4.818586 \n", - "1869 Bell County, KY 21 25.900000 11.446885 \n", - "1521 Union County, KY 21 16.300000 15.410182 \n", - "1743 Lewis County, KY 21 23.200000 5.170169 \n", - "535 Todd County, KY 21 22.000000 6.583954 \n", - "944 Grayson County, KY 21 19.700000 10.139429 \n", - "358 Anderson County, KY 21 11.400000 7.722777 \n", + " County State Poverty Rate Wages and Salary per Capita \\\n", + "1321 Montgomery County, KY 21 23.500000 15.881035 \n", + "656 Graves County, KY 21 17.900000 12.426165 \n", + "9 Jefferson County, KY 21 14.200000 35.990448 \n", + "920 Grayson County, KY 21 17.900000 11.018719 \n", + "1815 Owsley County, KY 21 45.100000 4.359246 \n", + "451 Grant County, KY 21 15.600000 7.902816 \n", + "447 Kenton County, KY 21 11.300000 18.808552 \n", + "743 Marshall County, KY 21 13.700000 16.654171 \n", + "1809 Clark County, KY 21 20.430784 17.591070 \n", + "1434 Hopkins County, KY 21 18.500000 16.228664 \n", + "1660 Clay County, KY 21 42.800000 7.114488 \n", + "1510 Union County, KY 21 19.400000 17.732498 \n", + "1064 Boyle County, KY 21 15.500000 20.321545 \n", + "1961 Adair County, KY 21 27.200000 8.379422 \n", + "1756 Breathitt County, KY 21 33.000000 8.735394 \n", "\n", " Government Transfers per Capita Medicare Transfers per Capita \\\n", - "1253 11.964175 2.948242 \n", - "997 7.495861 1.960841 \n", - "933 6.014126 1.071944 \n", - "713 6.061980 1.311061 \n", - "357 9.739244 2.831964 \n", - "962 10.445418 3.007630 \n", - "223 6.720423 1.350066 \n", - "1017 8.977512 2.171124 \n", - "1699 9.594358 2.015576 \n", - "1869 9.538232 1.971129 \n", - "1521 10.961823 2.686237 \n", - "1743 11.474494 2.794649 \n", - "535 8.336391 2.176189 \n", - "944 7.809289 1.998294 \n", - "358 7.308096 1.899991 \n", + "1321 8.173329 2.017834 \n", + "656 11.247675 2.984805 \n", + "9 9.287062 2.294696 \n", + "920 6.995480 1.463927 \n", + "1815 16.919987 2.861929 \n", + "451 6.414626 1.581160 \n", + "447 5.450023 1.184374 \n", + "743 9.731167 2.692509 \n", + "1809 5.768903 1.144135 \n", + "1434 8.579361 1.992881 \n", + "1660 12.574217 2.805054 \n", + "1510 9.080130 2.095810 \n", + "1064 9.870158 2.673707 \n", + "1961 11.054665 2.398944 \n", + "1756 16.249968 2.886312 \n", "\n", " Share of Population 65+ Total Population \\\n", - "1253 0.194275 26797 \n", - "997 0.150525 41435 \n", - "933 0.103278 95015 \n", - "713 0.146178 34499 \n", - "357 0.142133 49313 \n", - "962 0.169882 10990 \n", - "223 0.104949 292514 \n", - "1017 0.152546 42171 \n", - "1699 0.146101 13915 \n", - "1869 0.139935 29478 \n", - "1521 0.167024 14471 \n", - "1743 0.185085 13275 \n", - "535 0.144673 12428 \n", - "944 0.146518 25444 \n", - "358 0.136663 21747 \n", + "1321 0.135927 26860 \n", + "656 0.188483 37266 \n", + "9 0.166599 766757 \n", + "920 0.138491 24962 \n", + "1815 0.177699 4502 \n", + "451 0.100228 24544 \n", + "447 0.110031 153138 \n", + "743 0.200218 31261 \n", + "1809 0.125872 33407 \n", + "1434 0.150943 47051 \n", + "1660 0.131124 21186 \n", + "1510 0.134328 15276 \n", + "1064 0.196008 30060 \n", + "1961 0.173625 19162 \n", + "1756 0.149858 13366 \n", "\n", " Medicaid Transfers per Capita Unemployment Rate Date \\\n", - "1253 2.968643 8.3 2019-01-01 \n", - "997 1.426209 5.2 2007-01-01 \n", - "933 1.078955 5.4 2004-01-01 \n", - "713 0.888641 7.1 2002-01-01 \n", - "357 1.060611 7.9 2011-01-01 \n", - "962 2.249311 8.3 2008-01-01 \n", - "223 0.955715 7.8 2009-01-01 \n", - "1017 1.621197 12.3 2009-01-01 \n", - "1699 2.106990 15.2 2009-01-01 \n", - "1869 2.259345 8.6 2003-01-01 \n", - "1521 2.701217 5.0 2018-01-01 \n", - "1743 3.279235 8.9 2019-01-01 \n", - "535 1.402092 8.7 2011-01-01 \n", - "944 1.421122 8.1 2007-01-01 \n", - "358 0.715417 6.4 2013-01-01 \n", + "1321 1.176897 8.8 2012-01-01 \n", + "656 2.738310 4.6 2019-01-01 \n", + "9 1.991303 4.0 2019-01-01 \n", + "920 1.469075 7.1 2004-01-01 \n", + "1815 7.470229 10.4 2014-01-01 \n", + "451 1.058049 5.5 2007-01-01 \n", + "447 0.916748 4.6 2004-01-01 \n", + "743 1.120017 8.1 2012-01-01 \n", + "1809 1.079571 5.6 2002-01-01 \n", + "1434 1.311985 7.3 2008-01-01 \n", + "1660 3.442334 14.3 2013-01-01 \n", + "1510 1.654108 9.7 2010-01-01 \n", + "1064 1.772534 4.7 2019-01-01 \n", + "1961 3.568906 7.2 2015-01-01 \n", + "1756 5.836183 11.4 2014-01-01 \n", "\n", " Above Average Poverty Mean \n", - "1253 False \n", - "997 False \n", - "933 False \n", - "713 False \n", - "357 False \n", - "962 True \n", - "223 False \n", - "1017 False \n", - "1699 True \n", - "1869 True \n", - "1521 False \n", - "1743 True \n", - "535 True \n", - "944 False \n", - "358 False " + "1321 True \n", + "656 False \n", + "9 False \n", + "920 False \n", + "1815 True \n", + "451 False \n", + "447 False \n", + "743 False \n", + "1809 False \n", + "1434 False \n", + "1660 True \n", + "1510 False \n", + "1064 False \n", + "1961 True \n", + "1756 True " ] }, "execution_count": 28,