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.

1039 lines
1.9 MiB

2 years ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
"<a href='https://www.udemy.com/user/joseportilla/'><img src='../Pierian_Data_Logo.png'/></a>\n",
"___\n",
"<center><em>Copyright by Pierian Data Inc.</em></center>\n",
"<center><em>For more information, visit us at <a href='http://www.pieriandata.com'>www.pieriandata.com</a></em></center>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Random Forest - Regression\n",
"## Plus: An Additional Analysis of Various Regression Methods!\n",
"\n",
"## The Data\n",
"\n",
"We just got hired by a tunnel boring company which uses X-rays in an attempt to know rock density, ideally this will allow them to switch out boring heads on their equipment before having to mine through the rock!\n",
"\n",
"<img src='boring.jpg' height=400>\n",
"\n",
"They have given us some lab test results of signal strength returned in nHz to their sensors for various rock density types tested. You will notice it has almost a sine wave like relationship, where signal strength oscillates based off the density, the researchers are unsure why this is, but"
]
},
{
"cell_type": "code",
"execution_count": 178,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": 179,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(\"../DATA/rock_density_xray.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 180,
"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>Rebound Signal Strength nHz</th>\n",
" <th>Rock Density kg/m3</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>72.945124</td>\n",
" <td>2.456548</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>14.229877</td>\n",
" <td>2.601719</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>36.597334</td>\n",
" <td>1.967004</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>9.578899</td>\n",
" <td>2.300439</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>21.765897</td>\n",
" <td>2.452374</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Rebound Signal Strength nHz Rock Density kg/m3\n",
"0 72.945124 2.456548\n",
"1 14.229877 2.601719\n",
"2 36.597334 1.967004\n",
"3 9.578899 2.300439\n",
"4 21.765897 2.452374"
]
},
"execution_count": 180,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 181,
"metadata": {},
"outputs": [],
"source": [
"df.columns=['Signal',\"Density\"]"
]
},
{
"cell_type": "code",
"execution_count": 182,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='Signal', ylabel='Density'>"
]
},
"execution_count": 182,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAB9IAAAU2CAYAAADJT/3yAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAB7CAAAewgFu0HU+AAEAAElEQVR4nOz9fXRceV7f+3723qUtt7YBeVKaAC1VbI3lewyBQ2tkywbJ0z1okntyfM46IUzQuILNxZrMTdoJycmscyCK5yarbWDu6ZO+EPsSoB1o0fK4mQAnN9frEmy6PRY0lqwRszjJMkjTD5SUhIzElMN4C6tUu/b9Qy53ydZDPe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5cv7cpiC5J7624unD9ngYv3tTUwkrZCQ4AANSCjHQAAMrUZpmanM5UdezknYzODvUGPCIAAAAAAFALsqCbL+8VNLWworGJ2V0D5MU2elfODGjoYJLHBABQV3zKAABQpqybe2pHdLneXXF1fzUX8IgAAAAAAEC1yIIOh2rb6K3lqRYAAKgvAukAAJTJzeVrPL6ykvAAAAAAAKA+8l5Bt+eXNTYxu+t8vZgFPbWwrDyl3gNFGz0AQJgRSAcAoEyOXVtHFMe2AhoJAAAAAACoBVnQ4VBrG702SrsDAOqITxkAAMq0z7F1IOlUdWxv0lFnhx3wiAAAAAAAQKXIgg4P2ugBAMKMQDoAAGVa9wpKD6aqOjZ9LMVEGwAAAACAECALOjxoowcACDM+8QEAKFObZWr0aKriEu2ObWn0SIqJNgAAAAAAIUAWdHjQRg8AEGas6AMAUIE9CVOXTvXLMo2ybm+Zhi6n+9We4CMXAAAAAIAwIAs6PGijBwAIM1b1AQCoQMIydeJQl149PbD
"text/plain": [
"<Figure size 2400x1600 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(12,8),dpi=200)\n",
"sns.scatterplot(x='Signal',y='Density',data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Splitting the Data\n",
"\n",
"Let's split the data in order to be able to have a Test set for performance metric evaluation."
]
},
{
"cell_type": "code",
"execution_count": 198,
"metadata": {},
"outputs": [],
"source": [
"X = df['Signal'].values.reshape(-1,1) \n",
"y = df['Density']"
]
},
{
"cell_type": "code",
"execution_count": 199,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split"
]
},
{
"cell_type": "code",
"execution_count": 200,
"metadata": {},
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=101)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"-----\n",
"\n",
"# Linear Regression"
]
},
{
"cell_type": "code",
"execution_count": 201,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.linear_model import LinearRegression"
]
},
{
"cell_type": "code",
"execution_count": 202,
"metadata": {},
"outputs": [],
"source": [
"lr_model = LinearRegression()"
]
},
{
"cell_type": "code",
"execution_count": 203,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"LinearRegression()"
]
},
"execution_count": 203,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lr_model.fit(X_train,y_train)"
]
},
{
"cell_type": "code",
"execution_count": 204,
"metadata": {},
"outputs": [],
"source": [
"lr_preds = lr_model.predict(X_test)"
]
},
{
"cell_type": "code",
"execution_count": 205,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import mean_squared_error"
]
},
{
"cell_type": "code",
"execution_count": 206,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.2570051996584629"
]
},
"execution_count": 206,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.sqrt(mean_squared_error(y_test,lr_preds))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What does the fit look like?"
]
},
{
"cell_type": "code",
"execution_count": 208,
"metadata": {},
"outputs": [],
"source": [
"signal_range = np.arange(0,100)"
]
},
{
"cell_type": "code",
"execution_count": 210,
"metadata": {},
"outputs": [],
"source": [
"lr_output = lr_model.predict(signal_range.reshape(-1,1))"
]
},
{
"cell_type": "code",
"execution_count": 214,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x216f1c9c490>]"
]
},
"execution_count": 214,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAB9IAAAU2CAYAAADJT/3yAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAB7CAAAewgFu0HU+AAEAAElEQVR4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uqUqkolUqp2Ww+87HNZlOpVEr7+/tkpgMAAAAAgMCjRR4AYFoQSAcAYMja7bbS6XTXWeadTkdbW1s6Pz8f8cwAAAAAAACmEy3yAADThkA6AABD5DiOSqXSvZnoT2o2myqVSuyuBgAAAABgAsiCnixa5AEAphGBdAAAhigSiahYLPY1tlgsKhKJDHlGAAAAAADgLmRBTx4t8gAA08rwPG/Sc8CIGYaxJOlEkk5OTrS0tDThGQHA7LJtW/F4fKDxsVhsiDMCAAAAAABP0+l0VKlUlE6nnxnANU1T5XJZm5ubCoVCY5xhMDQaDSUSiZ6q+5mmqVqtJtM0RzgzAICfnJ6eanl5+fLbZc/zTgc9JxnpAAAMUavVmuh4AAAAAABwP7KgpwMt8gAA04xAOgAAQxSNRic6HgAAAAAA3K/dbiudTnfda7vT6Whra0vn5+cjnlmw0CIPADDNCKQDADBEi4uLWltb62usZVmUdQcAAAAAYMTIgp4etm3r6Oior7GHh4eq1+tDnhEAAG8ikA4AwBA5jqNsNtvX2Gw2y2IcAAAAAIARIwt6etAiDwAwzQikAwAwRJFIRJlMRqZp9jTONE1lMhkW4wAAAAAAjBhZ0NODFnkAgGlGIB0AgCGbn59XuVxWKBTq6vGhUEg7Ozuam5sb8cwAAAAAAABZ0NODFnkAgGlGIB0AgCELh8Pa3Nz
"text/plain": [
"<Figure size 2400x1600 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(12,8),dpi=200)\n",
"sns.scatterplot(x='Signal',y='Density',data=df,color='black')\n",
"plt.plot(signal_range,lr_output)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"# Polynomial Regression"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Attempting with a Polynomial Regression Model\n",
"\n",
"Let's explore why our standard regression approach of a polynomial could be difficult to fit here, keep in mind, we're in a fortunate situation where we can easily visualize results of y vs x."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Function to Help Run Models"
]
},
{
"cell_type": "code",
"execution_count": 223,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.linear_model import LinearRegression\n",
"model = LinearRegression()"
]
},
{
"cell_type": "code",
"execution_count": 224,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"LinearRegression()"
]
},
"execution_count": 224,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.fit(poly_features,y_train)"
]
},
{
"cell_type": "code",
"execution_count": 266,
"metadata": {},
"outputs": [],
"source": [
"def run_model(model,X_train,y_train,X_test,y_test):\n",
" \n",
" # Fit Model\n",
" model.fit(X_train,y_train)\n",
" \n",
" # Get Metrics\n",
" \n",
" preds = model.predict(X_test)\n",
" \n",
" rmse = np.sqrt(mean_squared_error(y_test,preds))\n",
" print(f'RMSE : {rmse}')\n",
" \n",
" # Plot results\n",
" signal_range = np.arange(0,100)\n",
" output = model.predict(signal_range.reshape(-1,1))\n",
" \n",
" \n",
" plt.figure(figsize=(12,6),dpi=150)\n",
" sns.scatterplot(x='Signal',y='Density',data=df,color='black')\n",
" plt.plot(signal_range,output)"
]
},
{
"cell_type": "code",
"execution_count": 267,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.15234870286353372\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXhc5Xk28PvMHM2i0TJaLVvyisGAsZHDFkBA1oYsNlmU0Chpm5AW7DZN26+2SNN9Sz7LztY2sUm+hNCmEUQtATtNyNoQBISQYJkIsAEbL5ItW9toGUmjWc73hzTnvGfmzMyZmTObdP+ui4tZziyWx/Z7nnne+5EURQEREREREREREREREWXPVug3QERERERERERERES0VLDoTkRERERERERERERkERbdiYiIiIiIiIiIiIgswqI7EREREREREREREZFFWHQnIiIiIiIiIiIiIrIIi+5ERERERERERERERBZh0Z2IiIiIiIiIiIiIyCIsuhMRERERERERERERWYRFdyIiIiIiIiIiIiIii7DoTkRERERERERERERkERbdiYiIiIiIiIiIiIgswqI7EREREREREREREZFFWHQnIiIiIiIiIiIiIrIIi+5ERERERERERERERBYpyaK7JEnlkiS9W5Kkr0mSdFySpDlJkvySJB2VJOlvJEmqyOA53ypJ0v9IkjQsSVJQkqRRSZJ+KEnSe3LxayAiIiIiIiIiIiKipUdSFKXQ7yFtkiT9PoCvLl59CUA/gCoANwGoBHAMwG2Kolw0+Xx/CuDzABQATwM4C2A1gBsBSAA+rSjKX2b5nocAlC8+NxEREREREREREREVp9UAZhRFacrkwaVadP89LBTYv6AoykvC7SsB/A+AbQC6FUXpMPFcDVgohNsAvFVRlMeF+24F8EMADgAbFUU5mcV7nnQ6nZWXXHJJpk9BRERERERERERERDl24sQJBAKBKUVRqjJ5fEkW3ZORJOlGAE8BCACoUhRlPsXx7wJwGMAPFEW53eD+RwHsAHCnoijfzuJ9vXDllVde+cILL2T6FERERERERERERESUY5s3b8aLL774oqIomzN5fElmuqdwdPH/TgB1Jo4PmHze0czeDhEREREREREREREtF0ux6L5h8f9BAGMmjv8lAB+AN0mSdJt4x2K8zNsAvALgCQvfIxEREREREREREREtQUux6P4ni/9/TFGUlF3siqJMAPgYgAiA/5UkqVeSpAclSeoF8DMAzwJ4W6qYGiIiIiIiIiIiIiIiudBvwEqSJL0DCwX0IIC/Nvs4RVEeliTp7QC+DeBm4a5JLAxSHUzjPSQKbecEVSIiIiIiIiIiIqIlbsl0ukuSdDmAbwKQAOxRFOVoioeIj/1zAD8G8HMAWwFULP7/pwD+AcDDlr9hIiIiIiIiIiIiIlpylkSnuyRJzQAeA1AD4HOKonwxjce+AcB+AM8BeL+iKJHFu34jSVI7gF8BeKckSW9XFOX7qZ4v0UTbxQ74K82+LyIiIiIiIiIiIiIqPSXf6S5JUi0WImDWArgfwO40n+J3Fv//HaHgDgBQFCUMrcv91mzeJxEREREREREREREtfSVddJckqQLA97HQQf4wgD9QFEVJ82laFv8/keD+6O016b9DIiIiIiIiIiIiIlpOSrboLkmSE8CjAK4H8AMAH1zsTE/X0OL/r01w/3WL/z+VwXMTERERERERERER0TJSkkV3SZLsALoBvAnAEwDeqyjKfIrHfFySpGOSJH0m5q5HFv//IUmS3hXzmDsAdACIAPiOFe+diIiIiIiIiIiIiJauUh2k+nEA71m8PALgy5IkGR23W1GUkcXL9QA2AVgZc8wjAHoAvB/AYUmSfgXgNQDroXW//6WiKMcte/dEREREREREREREtCSVatFdzFd/T8KjgL/DQlE+IUVRFEmS7gTwGIDfA7AVQCsAH4DvAfhXRVEey+K9EhEREREREREREdEyIaU/d5QyIUnSC1deeeWVL7zwQqHfChERERERERERERElsHnzZrz44osvKoqyOZPHl2SmOxERERERERERERFRMWLRnYiIiIiIiIiIiIjIIiy6ExERERERERERERFZhEV3IiIiIiIiIiIiIiKLsOhORERERERERERERGQRFt2JiIiIiIiIiIiIiCzCojsRERERERERERERkUVYdCciIiIiIiIiIiIisgiL7kREREREREREREREFpEL/QaIiAgIhUIIBALw+XwYHx9HTU0NvF4vnE4nZJl/VRMRERERERERlQp2uhMRFZjf70dPTw/a2trQ0tKCLVu2oKWlBW1tbejp6YHf7y/0WyQiIiIiIiIiIpNYdCciKiC/34/du3ejo6MDfX19uvv6+vrQ0dGBPXv2sPBOREREREQlLRQKwe/3Y3BwEP39/RgcHITf70coFCr0WyMishyL7kREBRIKhXDo0CEcPHgw6XEHDhzA4cOHuRglIiIiIipCLCanxt29RLTcsOhORFQggUAAe/fuNb7Tps9x7+rqQiAQyMO7IiIiIiIis1hMTo27e4loOWLRnYioQHw+H44ePRp3u/e238Oa/9OD2t/6Q/W2I0eOwOfz5fHdERERERFRMiwmp8bdvUS0XLHoTkRUIOPj43G3SWVOVF3/Xkj2MlRuewfsFbXqfSy6ExEREREVBxaT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pzMXbjjM0YVx0Z6c7EREREVHx8vv92L17Nzo6OnS57gDQ19eHjo4O7Nmzh4V3IqJlhEV3IippmSxwZVnGjh07sHPnzqTPvWvXLmzfvj1vW0HFIaqSpN1+lkV3IiIiIqKiFAqFcOjQIRw8eDDpcQcOHMDhw4cNd+ISEdHSw6I7EZWsbBa4Ho8H+/fvR3d3d1zUTGtrK7q7u7Fv3z54PJ5cvHVD54VO903C4NSz4zNQlPisdyIiIiIiKqxAIIC9e/fqbnOsuhxV178HNo9Xd3tXVxc
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"run_model(model,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Pipeline for Poly Orders"
]
},
{
"cell_type": "code",
"execution_count": 268,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.pipeline import make_pipeline"
]
},
{
"cell_type": "code",
"execution_count": 269,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.preprocessing import PolynomialFeatures"
]
},
{
"cell_type": "code",
"execution_count": 270,
"metadata": {},
"outputs": [],
"source": [
"pipe = make_pipeline(PolynomialFeatures(2),LinearRegression())"
]
},
{
"cell_type": "code",
"execution_count": 271,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.2817309563725596\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXwTZf4H8M+0gVDCkQCCkoiCFaShkOri1RTPXVFpUbeuGvdwu7tCPfCiYZe93EtsYVW8CuyB7mEW40+h9cIbW0/UFkzLVVAxwYOjoTCF0Gnn9we0ND1zz0zy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z5/Z57OLiYuTn53MqKBERERER9UiSJFRUVGDZsmV9tisvL0dlZWWPM3GJiCj5MOhORJoVzQDXYDBgyZIlcLlc3UrN2Gw2uFwuLF68GAaDIR5dJyIiIiKiJBAIBFBaWhpS27KyMgQCgTj3iIiI1ECQZVnpPqQEQRDqsrKysurq6pTuClHSEEURubm52LBhQ79tc3JyUFVV1S2ILkkSAoEA/H4//H4/jEYjFzsiIiIiIqKQ+Hw+WCyWkNt7vV6YzeY49oiIiGLBarWivr6+XpZlayT7M6JERJrl9/tDCrgDQE1NDfx+f7egu06ng06ng8Fg4OCXiIiIiIjC0tjYGFZ7v9/P6w4iohTAoDsRaRYHuOrUefZAY2MjTCYTZw8QERERUVIymUxhtTcajTF9fo69iYjUiTXdiUizlB7gUneiKMLtdsNut8NisSA7OxsWiwV2ux1utztoQVsiIiI
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"run_model(pipe,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Comparing Various Polynomial Orders"
]
},
{
"cell_type": "code",
"execution_count": 272,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.1417947898442399\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXwTZf4H8M+0KaEESsINCadFoKHQqni14Lm7rNqCWkXjscruCl13UVcaXHf3556yLayr7lHAXVmvrRoPaF0Vdb2oJ2gLpEWRm4RDjoSWaZt2mvn9URp6N0lzzCSf9+vFq2TyzORpO0mf+c73+T6CLMsgIiIiIiIiIiIiIqK+S4h2B4iIiIiIiIiIiIiIYgWD7kREREREREREREREIcKgOxERERERERERERFRiDDoTkREREREREREREQUIgy6ExERERERERERERGFCIPuREREREREREREREQhwqA7EREREREREREREVGIMOhORERERERERERERBQiDLoTEREREREREREREYUIg+5ERERERERERERERCHCoDsRERERERERERERUYgw6E5EREREREREREREFCIMuhMRERERERERERERhQiD7kREREREREREREREIaLKoLsgCAMEQZgvCMK/BEH4WhCEBkEQREEQtgiC8H+CIAwM4pjfEQThv4IgHBUEoUkQhOOCILwlCMK14fgeiIiIiIiIiIiIiCj2CLIsR7sPARME4UcAnjj9cDsAO4AUABcDGATgKwCXyLL8rZ/HuxfAXwDIAD4BcADAWAAXARAAPCzL8i/72OfDAAacPjYRERERERERERERKdNYAHWyLI8KZme1Bt1/gJYA+6OyLG9vs300gP8CyARQIsuyxY9jDUdLIDwBwHdkWf6gzXNzALwFoB+AVFmWd/ehzzVarXbQWWedFewhiIiIiIiIiIiIiCjMdu3aBY/HUyvLckow+6sy6N4TQRAuAvAxAA+AFFmWG3tpfw2AMgAbZFme28Xz6wHkAlggy/KLfehXVVpaWlpVVVWwhyAiIiIiIiIiIiKiMDObzaiurq6WZdkczP6qrOneiy2nv2oBDPWjvcfP4x4PrjtEREREREREREREFC9iMeg+6fTXJgAn/Gj/OQA3gMsFQbik7ROny8t8D8A3ADaGsI9EREREREREREREFINiMeh+z+mvb8qy3GsWuyzLJwH8EIAXwHuCIJQLgvC8IAjlAN4HsAnA93orU0NEREREREREREREpIl2B0JJEISr0BJAbwLwa3/3k2X5FUEQvg/gRQBZbZ6qQctCqs4A+tBd0XauoEpEREREREREREQU42Im010QhKkAngUgACiQZXlLL7u03fd+AO8A+BDADAADT399F8DvALwS8g4TERERERERERERUcyJiUx3QRCMAN4EYADwiCzLjwWw76UAVgL4EsANsix7Tz+1TRCEPACbAVwtCML3ZVl+o7fjdbei7ekM+DR/+0VERERERERERERE6qP6THdBEIagpQTMeABrASwN8BC3nf76apuAOwBAluVmnMlyn9OXfhIRERERERERERFR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ZFRUXweDxh7hERESmBIMtytPsQFwRBqEpLS0urqqqKdleIYoYoisjKysKWLVt6bZuZmYmNGzd2CqJLkgSPxwO32w232w29Xs/FjoiIiIiIyC9OpxMmk8nv9g6HA0ajMYw9IiKiUDCbzaiurq6WZdkczP6MKBGRarndbr8C7gBQUVEBt9vdKeiu0Wig0Wig0+k4+CUiIiIiooC4XK6A2rvdbl53EBHFAQbdiUi1OMBVprazB1wuFwwGA2cPEBEREVFMMhgMAbXX6/UhfX2OvYmIlIk13YlItaI9wKXORFGEzWZDdnY2TCYT0tPTYTKZkJ2dDZv
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"pipe = make_pipeline(PolynomialFeatures(10),LinearRegression())\n",
"run_model(pipe,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----\n",
"\n",
"## KNN Regression"
]
},
{
"cell_type": "code",
"execution_count": 273,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.neighbors import KNeighborsRegressor"
]
},
{
"cell_type": "code",
"execution_count": 274,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.15234870286353372\n",
"RMSE : 0.13730685016923655\n",
"RMSE : 0.13277855732740926\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXhc5Xk28PvMHM2i0TJaLVvyisGAsZHDFkBA1oYsNlmU0Chpm5AW7DZN26+2SNN9Sz7LztY2sUm+hNCmEUQtATtNyNoQBISQYJkIsAEbL5ItW9toGUmjWc73hzTnvGfmzMyZmTObdP+ui4tZziyWx/Z7nnne+5EURQEREREREREREREREWXPVug3QERERERERERERES0VLDoTkRERERERERERERkERbdiYiIiIiIiIiIiIgswqI7EREREREREREREZFFWHQnIiIiIiIiIiIiIrIIi+5ERERERERERERERBZh0Z2IiIiIiIiIiIiIyCIsuhMRERERERERERERWYRFdyIiIiIiIiIiIiIii7DoTkRERERERERERERkERbdiYiIiIiIiIiIiIgswqI7EREREREREREREZFFWHQnIiIiIiIiIiIiIrIIi+5ERERERERERERERBYpyaK7JEnlkiS9W5Kkr0mSdFySpDlJkvySJB2VJOlvJEmqyOA53ypJ0v9IkjQsSVJQkqRRSZJ+KEnSe3LxayAiIiIiIiIiIiKipUdSFKXQ7yFtkiT9PoCvLl59CUA/gCoANwGoBHAMwG2Kolw0+Xx/CuDzABQATwM4C2A1gBsBSAA+rSjKX2b5nocAlC8+NxEREREREREREREVp9UAZhRFacrkwaVadP89LBTYv6AoykvC7SsB/A+AbQC6FUXpMPFcDVgohNsAvFVRlMeF+24F8EMADgAbFUU5mcV7nnQ6nZWXXHJJpk9BRERERERERERERDl24sQJBAKBKUVRqjJ5fEkW3ZORJOlGAE8BCACoUhRlPsXx7wJwGMAPFEW53eD+RwHsAHCnoijfzuJ9vXDllVde+cILL2T6FERERERERERERESUY5s3b8aLL774oqIomzN5fElmuqdwdPH/TgB1Jo4PmHze0czeDhEREREREREREREtF0ux6L5h8f9BAGMmjv8lAB+AN0mSdJt4x2K8zNsAvALgCQvfIxEREREREREREREtQUux6P4ni/9/TFGUlF3siqJMAPgYgAiA/5UkqVeSpAclSeoF8DMAzwJ4W6qYGiIiIiIiIiIiIiIiudBvwEqSJL0DCwX0IIC/Nvs4RVEeliTp7QC+DeBm4a5JLAxSHUzjPSQKbecEVSIiIiIiIiIiIqIlbsl0ukuSdDmAbwKQAOxRFOVoioeIj/1zAD8G8HMAWwFULP7/pwD+AcDDlr9hIiIiIiIiIiIiIlpylkSnuyRJzQAeA1AD4HOKonwxjce+AcB+AM8BeL+iKJHFu34jSVI7gF8BeKckSW9XFOX7qZ4v0UTbxQ74K82+LyIiIiIiIiIiIiIqPSXf6S5JUi0WImDWArgfwO40n+J3Fv//HaHgDgBQFCUMrcv91mzeJxEREREREREREREtfSVddJckqQLA97HQQf4wgD9QFEVJ82laFv8/keD+6O016b9DIiIiIiIiIiIiIlpOSrboLkmSE8CjAK4H8AMAH1zsTE/X0OL/r01w/3WL/z+VwXMTERERERERERER0TJSkkV3SZLsALoBvAnAEwDeqyjKfIrHfFySpGOSJH0m5q5HFv//IUmS3hXzmDsAdACIAPiOFe+diIiIiIiIiIiIiJauUh2k+nEA71m8PALgy5IkGR23W1GUkcXL9QA2AVgZc8wjAHoAvB/AYUmSfgXgNQDroXW//6WiKMcte/dEREREREREREREtCSVatFdzFd/T8KjgL/DQlE+IUVRFEmS7gTwGIDfA7AVQCsAH4DvAfhXRVEey+K9EhEREREREREREdEyIaU/d5QyIUnSC1deeeWVL7zwQqHfChERERERERERERElsHnzZrz44osvKoqyOZPHl2SmOxERERERERERERFRMWLRnYiIiIiIiIiIiIjIIiy6ExERERERERERERFZhEV3IiIiIiIiIiIiIiKLsOhORERERERERERERGQRFt2JiIiIiIiIiIiIiCzCojsRERERERERERERkUVYdCciIiIiIiIiIiIisgiL7kREREREREREREREFpEL/QaIiAgIhUIIBALw+XwYHx9HTU0NvF4vnE4nZJl/VRMRERERERERlQp2uhMRFZjf70dPTw/a2trQ0tKCLVu2oKWlBW1tbejp6YHf7y/0WyQiIiIiIiIiIpNYdCciKiC/34/du3ejo6MDfX19uvv6+vrQ0dGBPXv2sPBOREREREQlLRQKwe/3Y3BwEP39/RgcHITf70coFCr0WyMishyL7kREBRIKhXDo0CEcPHgw6XEHDhzA4cOHuRglIiIiIipCLCanxt29RLTcsOhORFQggUAAe/fuNb7Tps9x7+rqQiAQyMO7IiIiIiIis1hMTo27e4loOWLRnYioQHw+H44ePRp3u/e238Oa/9OD2t/6Q/W2I0eOwOfz5fHdERERERFRMiwmp8bdvUS0XLHoTkRUIOPj43G3SWVOVF3/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RHrHoTkQlL90FrtPpRGdnp6nn7uzshNPpzMXbjjM0YVx0Z6c7EREREVHx8vv92L17Nzo6OnS57gDQ19eHjo4O7Nmzh4V3IqJlhEV3IippmSxwZVnGjh07sHPnzqTPvWvXLmzfvj1vW0HFIaqSpN1+lkV3IiIiIqKiFAqFcOjQIRw8eDDpcQcOHMDhw4cNd+ISEdHSw6I7EZWsbBa4Ho8H+/fvR3d3d1zUTGtrK7q7u7Fv3z54PJ5cvHVD54VO903C4NSz4zNQlPisdyIiIiIiKqxAIIC9e/fqbnOsuhxV178HNo9Xd3tXVxc
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdd1hb5/k38O9BAgHCIIan5I0XeEBsJ3GCnb0DziBJQ9s0cdvY7kg6bNKmu2+TFOymTTo8+mvTTROaxMZJGifNcEymF7bBjvGIB/JkCIwAgaTz/iEkHYEQGkf7+7muXNaRzpEeyAGec5/7uW9BFEUQEREREREREREREVHgEsI9ACIiIiIiIiIiIiKiWMGgOxERERERERERERGRTBh0JyIiIiIiIiIiIiKSCYPuREREREREREREREQyYdCdiIiIiIiIiIiIiEgmDLoTEREREREREREREcmEQXciIiIiIiIiIiIiIpkw6E5EREREREREREREJBMG3YmIiIiIiIiIiIiIZMKgOxERERERERERERGRTBh0JyIiIiIiIiIiIiKSCYPuREREREREREREREQyYdCdiIiIiIiIiIiIiEgmDLoTEREREREREREREckkKoPugiCkCoJwhyAIfxIE4ZAgCD2CIBgFQdgrCMKPBUFI8+M9bxAE4VVBEC4IgtAnCEKLIAhvCIJwZzC+BiIiIiIiIiIi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zAJPhzH7/gSiKh2QbPRERERERERERERHFpGgNukvrq9855F7AT2ELyg9JFEVREIT7ALwO4EsA5gIoAGAA8BqA34qi+HoAYyUiIiIiIiIiIiKiOCH43neU/CEIQkNeXl5eQ0NDuIdCREREREREREREREPIz8/HgQMHDoiimO/P8VFZ052IiIiIiIiIiIiIKBIx6E5EREREREREREREJBMG3YmIiIiIiIiIiIiIZMKgOxERERERERERERGRTBh0JyIiIiIiIiIiIiKSCYPuREREREREREREREQyYdCdiIiIiIiIiIiIiEgmDLoTEREREREREREREcmEQXciIiIiIiIiIiIiIpkowz0AIiICzGYzTCYTDAYD2trakJmZCY1GA5VKBaWSv6qJiIiIiIiIiKIFM92JiMLMaDSiuroaRUVF0Ol0mDNnDnQ6HYqKilBdXQ2j0RjuIRIRERERERERkZcYdCciCiOj0YhVq1ahrKwMdXV1Lq/V1dWhrKwMq1evZuCdiIiIiIiimtlshtFohF6vR319PfR6PYxGI8xmc7iHRkQkOwbdiYjCxGw2o6amBuvXr/e437p167BlyxZORomIiIiIIhCDycPj6l4iijcMuhMRhYnJZEJFRYVX+1ZWVsJkMgV5RERERERE5AsGk4fH1b1EFI8YdCciChODwYC9e/d6te+ePXtgMBiCOyAiIiIiIvIag8nD4+peIopXDLoTEYVJW1ubT/sz6E5EREREFBkYTPYOV/cSUbxi0J2IKEwyMzN92l+j0QRnIERERERE5BMGk73D1b1EFK8YdCciChONRoOCggKv9i0sLGTQnYiIiIgoQjCY7B2u7iWieMWgOxHFNbPZDKPRCL1ej/r6euj1ehiNxpAs/1SpVCgvL/dq3/LycqhUqiCPiIiIiIiIvMFgsne4upeI4hWD7kQUt4xGI6qrq1FUVASdToc5c+ZAp9OhqKgI1dXVQW94pFQqUVJSghUrVnjcb+XKlSguLoZSqQzqeIiIiIiIyDsMJnuHq3uJKF4x6E5EccloNGLVqlUoKytDXV2dy2t1dXUoKyvD6tWrgx54V6vVWLt2LaqqqgZNRgsKClBVVYU1a9ZArVYHdRxEREREROQ9BpO9w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wj3
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzde1xUZf4H8M+BgQFGcca7zngnL4woZFYm2r3sAnahLNputqXUrrWtYNvu/mrb3Qx02y5baLVZbRsZXRTayu4GlqUF6IA3vDPekRE4ysAw5/cHMtyHuc+cmc/79fIlZ+Y5Zx6Gw/Cc7/k+30eQJAlEREREREREREREROS+MH93gIiIiIiIiIiIiIgoWDDoTkRERERERERERETkIQy6ExERERERERERERF5CIPuREREREREREREREQewqA7EREREREREREREZGHMOhOREREREREREREROQhDLoTEREREREREREREXkIg+5ERERERERERERERB7CoDsRERERERERERERkYcw6E5ERERERERERERE5CEMuhMREREREREREREReQiD7kREREREREREREREHsKgOxERERERERERERGRhzDoTkRERERERERERETkIbIMuguCECMIwg2CIPxbEIQdgiA0CIIgCoJQJgjC/wmC0MeFY14pCML/BEE4LghCkyAI1YIgfC4Iwo3e+B6IiIiIiIiIiIiIKPgIkiT5uw9OEwTh1wBePbu5DYABQCyAiwD0BbAdwMWSJB1z8HiPAPgnAAnADwAOAhgBYAYAAcDTkiT90c0+HwEQc/bYRERERERERERERBSYRgA4LUnSUFd2lmvQ/W60BNifkyRpW7vHhwH4H4AkAHmSJKU7cKxBaAmEhwG4UpKk9e2emw3gcwCRAOIkSdrjRp9rlUpl33Hjxrl6CCIiIiIiIiIiIiLyst27d8NsNtdJkhTryv6yDLrbIwjCDADfAzADiJUkqbGX9tcDKASwTpKkOd08vxZAKoB5kiS950a/yuPj4+PLy8tdPQQREREREREREREReZler0dFRUWFJEl6V/aXZU33XpSd/V8JYIAD7c0OHrfate4QERERERERERERUagIxqD72LP/NwE46UD7nwCYAFwmCMLF7Z84W17magC7ABR5sI9EREREREREREREFISCMej+8Nn/P5MkqdcsdkmSTgG4D4AVwDeCIBQLgvCuIAjFAL4FsAnA1b2VqSEiIiIiIiIiIiIiUvi7A54kCMK1aAmgNwH4s6P7SZL0oSAI1wB4D8DMdk/VomUhVaMTfeipaDtXUCUiIiIiIiIiIiIKckGT6S4IwkQAbwMQAGRKklTWyy7t9/09gC8BfAdgCoA+Z///GsBTAD70eIeJiIiIiIiIiIiIKOgERaa7IAhaAJ8B0AB4VpKk553Y9xIAywH8AuAWSZKsZ5/aKghCGoDNAK4TBOEaSZI+7e14Pa1oezYDPt7RfhERERERERERERGR/Mg+010QhP5oKQEzCsAqAIudPMSdZ///qF3AHQAgSVIz2rLcZ7vTTyIiIiIiIiIiIiIKfrIOuguC0AfAp2jJIP8QwP2SJElOHkZ39v9TPTzf+rjG+R4SERERERERERERUSiRbdBdEAQlgLUAzgewDsDtZzPTnXXk7P/n9fD89LP/73Ph2EREREREREREREQUQmQZdBcEIRxAHoDLABQBuEmSpMZe9vmNIAjbBUFY2umpNWf/v0MQhOs77TMXQDoAK4CPPNF3IiIiIiIiIiIiIgpecl1I9TcAbjz79QkALwuC0F27xZIknTj79UAAEwAM69RmDYB8ALcAKBQEYTOAvQDGoC37/Y+SJO3wWO+JiIiIiIiIiIiIKCjJNejevr76jT22Ap5ES1C+R5IkSYIgzAPwGYC7AUwBkAjABOATAC9KkvSZG30lIiIiIiIiIiIiohAhOL/uKLlCEITy+Pj4+PLycn93hYiIiIiIiIiIiIh6oNfrUVFRUSFJkt6V/WVZ052IiIiIiIiIiIiIKBAx6E5ERERERERERERE5CEMuhMREREREREREREReQiD7kREREREREREREREHsKgOxERERERERERERGRhzDoTkRERERERERERETkIQy6ExERERERERERERF5CIPuREREREREREREREQewqA7EREREREREREREZGHKPzdASIiAiwWC8xmM0wmE2pqaqDRaKBWq6FUKqFQ8KOaiIiIiIiIiEg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oWiwwxfIqJgxk9/Igo5Go3GqfahuugRERERERH1rjWYrFQqoVarYTKZsHv3bmg0GmZyExGFKNZ0J6KgYLFYIIoijEYjDAYDjEYjRFHsdhFUtVrdpZZgT5KSkhh0JyIiIiIiu0RRRH5+PpKTk6HT6ZCQkACdTofk5GTk5+dDFEV/d5GIiHyIQXcikj1nB7hKpRJZWVkOHTsrKwtKpdIb3SYiIiIioiAgiiIWL16M9PT0DnXdAaC0tBTp6enIzMxk4J2IKIQw6E5EsubKAFehUCA1NRULFy60e+yMjAykpKRwKigREREREXXLYrGgoKAAK1assNsuNzcXhYWF3c7EJSKi4MOgOxHJljsDXJVKheXLlyMvL69LqZnExETk5eVh2bJlUKlU3ug6EREREREFAbPZjOzsbIfa5uTkwGw2e7lHREQUCARJkvzdh5AgCEJ5fHx8fHl5ub+7QhQ0RFHEzJkzUVZW1mvbpKQkFBUVdQmiWywWmM1mmEwmmEwmqNVqLnZEREREREQOMRqN0Ol0DrevqqqCVqv1Yo+IiMgT9Ho9KioqKiRJ0ruyPyNKRCRbJpPJoYA7AJSUlMBkMnUJuisUCigUCqhUKg5+iYiIiIjIKTU1NU61N5lMvO4gIgoBDLoTkWxxgBuY2s8eqKmpgUaj4ewBIiIiIgpKGo3GqfZqtdqjr8+xNxFRYGJNdyKSLX8PcKkrURSRn5+P5ORk6HQ6JCQkQKf
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"preds = {}\n",
"k_values = [1,5,10]\n",
"for n in k_values:\n",
" \n",
" \n",
" model = KNeighborsRegressor(n_neighbors=n)\n",
" run_model(model,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"## Decision Tree Regression"
]
},
{
"cell_type": "code",
"execution_count": 275,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.tree import DecisionTreeRegressor"
]
},
{
"cell_type": "code",
"execution_count": 276,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.15234870286353372\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXhc5Xk28PvMHM2i0TJaLVvyisGAsZHDFkBA1oYsNlmU0Chpm5AW7DZN26+2SNN9Sz7LztY2sUm+hNCmEUQtATtNyNoQBISQYJkIsAEbL5ItW9toGUmjWc73hzTnvGfmzMyZmTObdP+ui4tZziyWx/Z7nnne+5EURQEREREREREREREREWXPVug3QERERERERERERES0VLDoTkRERERERERERERkERbdiYiIiIiIiIiIiIgswqI7EREREREREREREZFFWHQnIiIiIiIiIiIiIrIIi+5ERERERERERERERBZh0Z2IiIiIiIiIiIiIyCIsuhMRERERERERERERWYRFdyIiIiIiIiIiIiIii7DoTkRERERERERERERkERbdiYiIiIiIiIiIiIgswqI7EREREREREREREZFFWHQnIiIiIiIiIiIiIrIIi+5ERERERERERERERBYpyaK7JEnlkiS9W5Kkr0mSdFySpDlJkvySJB2VJOlvJEmqyOA53ypJ0v9IkjQsSVJQkqRRSZJ+KEnSe3LxayAiIiIiIiIiIiKipUdSFKXQ7yFtkiT9PoCvLl59CUA/gCoANwGoBHAMwG2Kolw0+Xx/CuDzABQATwM4C2A1gBsBSAA+rSjKX2b5nocAlC8+NxEREREREREREREVp9UAZhRFacrkwaVadP89LBTYv6AoykvC7SsB/A+AbQC6FUXpMPFcDVgohNsAvFVRlMeF+24F8EMADgAbFUU5mcV7nnQ6nZWXXHJJpk9BRERERERERERERDl24sQJBAKBKUVRqjJ5fEkW3ZORJOlGAE8BCACoUhRlPsXx7wJwGMAPFEW53eD+RwHsAHCnoijfzuJ9vXDllVde+cILL2T6FERERERERERERESUY5s3b8aLL774oqIomzN5fElmuqdwdPH/TgB1Jo4PmHze0czeDhEREREREREREREtF0ux6L5h8f9BAGMmjv8lAB+AN0mSdJt4x2K8zNsAvALgCQvfIxEREREREREREREtQUux6P4ni/9/TFGUlF3siqJMAPgYgAiA/5UkqVeSpAclSeoF8DMAzwJ4W6qYGiIiIiIiIiIiIiIiudBvwEqSJL0DCwX0IIC/Nvs4RVEeliTp7QC+DeBm4a5JLAxSHUzjPSQKbecEVSIiIiIiIiIiIqIlbsl0ukuSdDmAbwKQAOxRFOVoioeIj/1zAD8G8HMAWwFULP7/pwD+AcDDlr9hIiIiIiIiIiIiIlpylkSnuyRJzQAeA1AD4HOKonwxjce+AcB+AM8BeL+iKJHFu34jSVI7gF8BeKckSW9XFOX7qZ4v0UTbxQ74K82+LyIiIiIiIiIiIiIqPSXf6S5JUi0WImDWArgfwO40n+J3Fv//HaHgDgBQFCUMrcv91mzeJxEREREREREREREtfSVddJckqQLA97HQQf4wgD9QFEVJ82laFv8/keD+6O016b9DIiIiIiIiIiIiIlpOSrboLkmSE8CjAK4H8AMAH1zsTE/X0OL/r01w/3WL/z+VwXMTERERERERERER0TJSkkV3SZLsALoBvAnAEwDeqyjKfIrHfFySpGOSJH0m5q5HFv//IUmS3hXzmDsAdACIAPiOFe+diIiIiIiIiIiIiJauUh2k+nEA71m8PALgy5IkGR23W1GUkcXL9QA2AVgZc8wjAHoAvB/AYUmSfgXgNQDroXW//6WiKMcte/dEREREREREREREtCSVatFdzFd/T8KjgL/DQlE+IUVRFEmS7gTwGIDfA7AVQCsAH4DvAfhXRVEey+K9EhEREREREREREdEyIaU/d5QyIUnSC1deeeWVL7zwQqHfChERERERERERERElsHnzZrz44osvKoqyOZPHl2SmOxERERERERERERFRMWLRnYiIiIiIiIiIiIjIIiy6ExERERERERERERFZhEV3IiIiIiIiIiIiIiKLsOhORERERERERERERGQRFt2JiIiIiIiIiIiIiCzCojsRERERERERERERkUVYdCciIiIiIiIiIiIisgiL7kRERERERERE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PRMuWz+fD0aNHTR175MgR+Hy+vC0AL0zOxd02MD6DS1dU5uX1iYiIiIjInGgx+bbbbsPevXt1sZWtra249957sX37dhaToe3u3b59O3w+H3w+H7xeL7xeL5xO57L+UoKIlib+rUZEy874+Hhax/t8PjQ3N+fo3WjCEQUXp+K76s+MsehORERERFSMjIrJ9fX1qKqqQllZGYvJAlmW1R2++Ti/IiIqJP7tT0TLTk1NTVrH52vo0eh0AOGIEnf7mbGZvLw+ERERERGlL1pMdjqd8Hq98Pl8OHHiBGpqatjJTUS0TDHTnYiWhFAoBL/fj8HBQfT392NwcBB+v99wCKrX643LEkxk27ZteSu6DxlEywDA2bHZvLw+ERERERFlxu/3o6enB21tbWhpacGWLVvQ0tKCtrY29PT0wO/3F/otEhFRHrHoTkQlL90FrtPpRGdnp6nn7uzshNPpzMXbjjM0YVx0Z6c7EREREVHx8vv92L17Nzo6OnS57gDQ19eHjo4O7Nmzh4V3IqJlhEV3IippmSxwZVnGjh07sHPnzqTPvWvXLmzfvj1vW0HFIaqSpN1+lkV3IiIiIqKiFAqFcOjQIRw8eDDpcQcOHMDhw4cNd+ISEdHSw6I7EZWsbBa4Ho8H+/fvR3d3d1zUTGtrK7q7u7Fv3z54PJ5cvHVD54VO903C4NSz4zNQlPisdyIiIiIiKqxAIIC9e/fqbnOsuhxV178HNo9Xd3tXVxc
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"model = DecisionTreeRegressor()\n",
"\n",
"run_model(model,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "code",
"execution_count": 277,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"270"
]
},
"execution_count": 277,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.get_n_leaves()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----\n",
"\n",
"## Support Vector Regression"
]
},
{
"cell_type": "code",
"execution_count": 282,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.svm import SVR"
]
},
{
"cell_type": "code",
"execution_count": 283,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import GridSearchCV"
]
},
{
"cell_type": "code",
"execution_count": 284,
"metadata": {},
"outputs": [],
"source": [
"param_grid = {'C':[0.01,0.1,1,5,10,100,1000],'gamma':['auto','scale']}\n",
"svr = SVR()"
]
},
{
"cell_type": "code",
"execution_count": 285,
"metadata": {},
"outputs": [],
"source": [
"grid = GridSearchCV(svr,param_grid)"
]
},
{
"cell_type": "code",
"execution_count": 286,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.12634668775105407\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXwTZf4H8M+0adOS0ibckAByKNJQaFVApeC5ikeraFe0XogHdHXR3aXFZXd/uhfYwnqvgLvK4lUxHtCqK16rUi9AWyAtAuWShBsaCkObNu38/mib3m2SJpmZ5PN+vXiVmTwzeZqm6TPf+T7fR5AkCURERERERERERERE1HMRcneAiIiIiIiIiIiIiChUMOhOREREREREREREROQnDLoTEREREREREREREfkJg+5ERERERERERERERH7CoDsRERERERERERERkZ8w6E5ERERERERERERE5CcMuhMRERERERERERER+QmD7kREREREREREREREfsKgOxERERERERERERGRnzDoTkRERERERERERETkJwy6ExERERERERERERH5CYPuRERERERERERERER+wqA7EREREREREREREZGfMOhOREREREREREREROQnqgy6C4LQSxCEGwVBeEkQhO2CIFQLgiAKgrBZEIT/EwQhzodz/kIQhA8EQTgqCEKtIAjHBUH4WBCEGYH4HoiIiIiIiIiIiIgo9AiSJMndB68JgnAfgH81bm4DYAUQD+BiAL0B/ATgEkmSjnh4v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/dZ7IiIiIiIiIiIiIgpJag26t6yvPqPTVsDjaAjKd0qSJEkQhJkAPgJwN4DxAJIBOAB8COA5SZI+6kFfiYiIiIiIiIiIiChMCN6vO0q+EAShNDExMbG0tFTurhARERERERERERFRJ8xmM8rKysokSTL7crwqa7oTERERERERERERESkRg+5ERERERERERERERH7CoDsRERERERERERERkZ8w6E5ERERERERERERE5CcMuhMRERERERERERER+QmD7kREREREREREREREfsKgOxERERERERERERGRnzDoTkRERERERERERETkJwy6ExERERERERERERH5iUbuDhAREeByueB0OuFwOFBRUQGDwQC9Xg+tVguNhh/VRERERERERERqwUx3IiKZiaIIi8WC1NRUmEwmJCUlwWQyITU1FRaLBaIoyt1FIiIiIiIiIiLyEIPuREQyEkUR8+fPR2ZmJkpKSlo9VlJSgszMTGRnZzPwTkREREREquZyuSCKIux2O6xWK+x2O0RRhMvlkrtrRER+x6A7EZFMXC4XCgoKsHz58i7bLVu2DIWFhRyMEhEREREpEIPJ3ePsXiIKNwy6ExHJxOl0Ijc316O2eXl5cDqdAe4RERERERF5g8Hk7nF2LxGFIwbdiYhk4nA4sHnzZo/aFhcXw+FwBLZDRERERETkMQaTu8fZvUQUrhh0JyKSSUVFhVftGXQnIiIiIlIGBpM9w9m9RBSuGHQnIpKJwWDwqr1erw9MR4iIiIiIyCsMJnuGs3uJKFwx6E5EJBO9Xo/k5GSP2qakpDDoTkRERESkEAwme4aze4koXDHoTkRhzeVyQRRF2O12WK1W2O12iKIYlOmfWq0WOTk5HrXNycmBVqsNcI+IiIiIiMgTDCZ7hrN7iShcMehORGFLFEVYLBakpqbCZDIhKSkJJpMJqampsFgsAV/wSKPRID09HXPnzu2yXVZWFtLS0qDRaALaHyIiIiIi8gyDyZ7h7F4iClcMuhNRWBJFEfPnz0dmZiZKSkpaPVZSUoLMzExkZ2cHPPCu0+mwdOlS5OfntxuMJicnIz8/H0uWLIFOpwtoP4iIiIiIyHMMJnuGs3uJKFwx6E5EYcflcqGgoADLly/vst2yZctQWFgY8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size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"run_model(grid,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "code",
"execution_count": 287,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SVR(C=1000)"
]
},
"execution_count": 287,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"grid.best_estimator_"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"## Random Forest Regression"
]
},
{
"cell_type": "code",
"execution_count": 288,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.ensemble import RandomForestRegressor"
]
},
{
"cell_type": "code",
"execution_count": 289,
"metadata": {},
"outputs": [],
"source": [
"# help(RandomForestRegressor)"
]
},
{
"cell_type": "code",
"execution_count": 290,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.1417613358931285\n",
"RMSE : 0.133281449397454\n",
"RMSE : 0.13699094997283662\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXhc5Xk+/vvMjDSSRstosSRb8iJ5t7wCBhJkQ1gSSLCBxAmJ0jQJacBu8yNpayuU7ktKbdMG2qY2NCkl3zQClASwkwAhEMBiCQYs2/K+25Js7aNlJI00mvP7YzTnvGc0+5xZdX+ui4tZziy2x/J7nnne+5FkWQYREREREREREREREUXPkOg3QERERERERERERESULlh0JyIiIiIiIiIiIiLSCYvuREREREREREREREQ6YdGdiIiIiIiIiIiIiEgnLLoTEREREREREREREemERXciIiIiIiIiIiIiIp2w6E5EREREREREREREpBMW3YmIiIiIiIiIiIiIdMKiOxERERERERERERGRTlh0JyIiIiIiIiI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Bdmfz/NX7uXzv5//MRPDcRERERERERERERTSMpWXSXJMkIoAHAzQD2AfisLMtjQR7zLUmSjkuS9IjXXS9M/v/LkiTd6fWYuwDUAXABeF6P905ERERERERERERE6StVB6l+C8A9k5e7AfyXJEm+jtsqy3L35OUSAIsBzPQ65gUAjQA+D2CvJEkfADgHoApq9/tfyrJ8Qrd3T0RERERERERERERpKVWL7mK++j1+jwL+Du6ivF+yLMuSJN0L4GUAXwWwEsBqADYAvwbwH7IsvxzFeyUiIiIiIiIiIiKiaUIKf+4oRUKSpCPLli1bduTIkUS/FSIiIiIiIiIiIiLyo6amBkePHj0qy3JNJI9PyUx3IiIiIiIiIiIiIqJkxKI7EREREREREREREZFOWHQnIiIiIiIiIiIiItIJi+5ERERERERERERERDph0Z2IiIiIiIiIiIiISCcsuhMRERERERERERER6YRFdyIiIiIiIiIiIiIinbDoTkRERERERERERESkExbdiYiIiIiIiIiIiIh0Ykr0GyAiIsDpdMLhcMBms6Gvrw+FhYWwWq0wm80wmfijmoiIiIiIiIgoVbDTnYgowex2OxobG1FbW4vKykqsWLEClZWVqK2tRWNjI+x2e6LfIhERERERERERhYhFdyKiBLLb7di6dSvq6urQ3Nysua+5uRl1dXXYtm0bC+9ERERERJTSnE4n7HY72tra0NLSgra2NtjtdjidzkS/NSIi3bHoTkSUIE6nE3v27MHu3bsDHrdr1y7s3buXi1EiIiIioiTEYnJw3N1LRNMNi+5ERAnicDiwffv2kI7dsWMHHA5HjN8RERERERGFg8Xk4Li7l4imIxbdiYgSxGaz4eDBgyEde+DAAdhstti+ISIiIiIiChmLycFxdy8RTVcsuhMRJUhfX19Yx7PoTkRERESUHFhMDg139xLRdMWiOxFRghQWFoZ1vNVqjc0bISIiIiKisLCYHBru7iWi6YpFdyKiBLFarVi9enVIx65Zs4ZFdyIiIiKiJMFicmi4u5eIpisW3YloWnM6nbDb7Whra0NLSwva2tpgt9vjsv3TbDajvr4+pGPr6+thNptj/I6IiIiIiCgULCaHhrt7iWi6YtGdi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2ux033HADDh48GPTYNWvWYN++fVOK6E6nEw6HAzabDTabDVarlcOOiIiIiIgoJG1tbaisrFSum2evQHndIwAAl8OOS499EYBad2ltbUVFRUW83yYREYWppqYGR48ePSrLck0kj2dFiYhSls1mC6ngDgAHDhy
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXwb5Z0/8M9IsmVbPmTHiZNYOXFO54SELeBACz2ANgGKKa27PUi3JGm7tL/dxHTZ3e5uuy3N0YNeCbRbervUPUJCW+5CMdCSQJzgXM7lJLbjK7F8yLZsSfP7w/bMM7JujU5/3q8Xr2ikkTQ2sv3Mdz7P95FkWQYREREREREREREREUXPkOgDICIiIiIiIiIiIiJKFyy6ExERERERERERERHphEV3IiIiIiIiIiIiIiKdsOhORERERERERERERKQTFt2JiIiIiIiIiIiIiHTCojsRERERERERERERkU5YdCciIiIiIiIiIiIi0gmL7kREREREREREREREOmHRnYiIiIiIiIiIiIhIJyy6ExERERERERERERHphEV3IiIiIiIiIiIiIiKdsOhORERERERERERERKQTFt2JiIiIiIiIiIiIiHTCojsRERERERERERERkU5SsuguSVKOJEl3SpL0f5IknZQkaUiSJIckSYclSfqSJEm5EbzmeyRJ+qMkSZ2SJI1IknRZkqRnJUm6KxZfAxERERERERERERGlH0mW5UQfQ9gkSfonAD8c2zwOoAFAPoDrAeQBOAHgJlmWO0J8vS8A+BYAGcDrAC4CmAXgOgASgK/JsvzvUR5zG4CcsdcmIiIiIiIiIiIiouQ0C8CALMvTI3lyqhbdP4HRAvu3ZVk+Ltw/A8AfAawGUCPLclUIrzUVo4Vw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B2LxFNViy6E9Gk43Q6sX379pD23bFjB5xOZ4yPaHQwarFYUFpaivLycpSWlsJisXDQSURERESUhFhMDh1n9xLRZCTJspzoY5gUJEk6unTp0qVHjx5N9KEQTXotLS2w2Wwh79/c3IzS0tIYHhEREREREaUih8OB/fv3Y/v27Zq2latWrcKDDz6I9evXs5g8xuVywel0wm63w263w2q1wmq1wmw2T+qLEkSUnMrLy3Hs2LFjsiyXR/J8/lYjokmnu7s7rP3tdjuL7kRERERENMF4q8j169crxeTi4mLk5+cjIyODxWSByWTSzPAlIkpn/O1PRJNOYWFhWPtP1kWPiIiIiIgouPFistlshtVqhd1ux5kzZ1BYWMgkNxHRJMWe7kSUFlwuFxwOB1paWtDQ0ICWlhY4HA6fi6BardYJvQT9Wb16NYvuREREREQUkMPhQG1tLSoqKmCz2bB8+XLYbDZUVFSgtrYWDocj0YdIRERxxKI7EaW8cAe4ZrMZ1dXVIb12dXU1zGZzLA6biIiIiIjSgMPhwNatW1FVVaXp6w4A9fX1qKqqwrZt21h4JyKaRFh0J6KUFskA12QyYcOGDdi8eXPA196yZQvWr1/PqaBEREREROSTy+XCvn37sGfPnoD77d69G/v37/c5E5eIiNIPi+5ElLKiGeBaLBbs2rULNTU1E1rNrFq1CjU1Ndi5cycsFkssDp2IiIiIiNKA0+nE9u3bQ9p3x44dcDqdMT4iIiJKBpIsy4k+hklBkqSjS5cuXXr06NFEHwpR2nA4HLjhhhtw+PDhoPuuXr0ar7zyyoQiusvlgtPphN1uh91uh9Vq5WJHREREREQUkpaWFthstpD3b25uRmlpaQyPiIiI9FBeXo5jx44dk2W5PJLns6JERCnLbreHVHAHgEOHDsFut08ouptMJphMJlgsFg5+iYiIiIgoLN3d3WHtb7fbed5BRDQJsOhORCmLA9zkJM4e6O7
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeXhbZ5k3/u+RZMu2vMhLVstxFrdp4iZxUro7KVAKZUlowdAZs5fSJANTZkkM05dZXt4ZSpKylPkNSTtAp8MSigdoExi6UOji7m22OvueWFm9yItsy5Z0fn/IOuc5spYj6Wj193NdvSLZR9JxqiTPuXU/31uSZRlERERERERERERERJQ8U6ZPgIiIiIiIiIiIiIgoX7DoTkRERERERERERERkEBbdiYiIiIiIiIiIiIgMwqI7EREREREREREREZFBWHQnIiIiIiIiIiIiIjIIi+5ERERERERERERERAZh0Z2IiIiIiIiIiIiIyCAsuhMRERERERERERERGYRFdyIiIiIiIiIiIiIig7DoTkRERERERERERERkEBbdiYiIiIiIiIiIiIgMwqI7EREREREREREREZFBWHQnIiIiIiIiIiIiIjIIi+5ERERERERERERERAbJyaK7JEklkiTdIUnSjyVJOixJ0qgkSW5JkvZKkvRPkiSVJvCct0mS9HtJki5LkjQuSVKPJEnPSJJ0Zyp+BiIiIiIiIiIiIiLKP5Isy5k+h7hJknQPgP+cuHsQQCeAcgA3ASgDcAjALbIsX9L5fH8D4HsAZACvAjgLoA7AjQAkAN+SZfn/JHnOFwCUTDw3EREREREREREREWWnOgDDsizPTOTBuVp0/xwCBfbvy7J8UPj6LAC/B7AcwHZZllt1PNc0BArhJgC3ybL8gvC9VQCeAVAIoEGW5RNJnPOA1WotW7BgQaJPQUREREREREREREQpdvz4cXg8nkFZlssTeXxOFt2jkSTpRgCvAPAAKJdleSzG8R8BsBPA07Is3x7m+08CWAPgLlmWf5XEee1fvHjx4v379yf6FERERERERERERESUYo2NjThw4MABWZYbE3l8Tma6x7B34lcrgGodx3t0Pm9PYqdDRERERERERERERFNFPhbd50/8Og6gV8fxbwBwAXivJEm3iN+YiJf5AICjAF4y8ByJiIiIiIiIiIiIKA/lY9H9qxO/PiXLcswudlmW+wF8EYAfwJ8lSeqQJOmXkiR1AHgewJsAPhArpoaIiIiIiIiIiIiIyJLpEzCSJEkfQqCAPg7gH/U+Tpbl30iS9EEAvwJws/CtAQQGqTrjOIdIoe2coEpERERERERERESU5/Km012SpKsA/AyABGCjLMt7YzxEfOzfA/gjgBcBLAVQOvHrnwB8E8BvDD9hIiIiIiIiIiIiIso7edHpLklSLYCnAFQC+K4syw/F8dh3A3gQwC4An5Bl2T/xrXckSWoB8BaAD0uS9EFZlv8Q6/kiTbSd6IBfrPe8iIiIiIiIiIiIiCj35HynuyRJVQhEwNQDeBTAhjif4jMTv/5WKLgDAGRZ9kHtcl+VzHkSERERERERERERUf7L6aK7JEmlAP6AQAf5bwB8SZZlOc6ncUz82h/h+8GvV8Z/hkREREREREREREQ0leRs0V2SJCuAJwFcB+BpAH850ZkerwsTv74rwvevnfj1VALPTURERERERERERERTSE4W3SVJMgPYDuC9AF4C8DFZlsdiPOYrkiQdkiTpgZBvPTHx66ckSfpIyGM+CqAVgB/Ab404dyIiIiIiIiIiIiLKX7k6SPUrAO6cuN0N4IeSJIU7boMsy90Tt2sALAQwK+SYJwC0A/gEgJ2SJL0F4CSAeVC73/+PLMuHDTt7IiIiIiIiIiIiIspLuVp0F/PV74x4FPAvCBTlI5JlWZYk6S4ATwH4HIClAJoAuAD8L4B/l2X5qSTOlYiIiIiIiIiIiIimCCn+uaOUCEmS9i9evHjx/v37M30qRERERERERERERBRBY2MjDhw4cECW5cZEHp+Tme5ERERERERERERERNmIRXciIiIiIiIiIiIiIoOw6E5EREREREREREREZBAW3YmIiIiIiIiIiIiIDMKiOxERERERERERERGRQVh0JyIiIiIiIiIiIiIyCIvuREREREREREREREQGYdGdiIiIiIiIiIiIiMggLLoTERERERERERERERnEkukTICIiwOv1wuPxwOVyoa+vD5WVlbDb7bBarbBY+Fc1EREREREREVGuYKc7EVGGud1utLe3o7m5GQ6HA0uWLIHD4UBzczPa29vh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CMiIiIiIootWEy2Wq2w2+1wuVw4fvw4Kisr2clNRDRFMdOdiPKC1+uF2+2G0+lEZ2cnnE4n3G532CGodrt9UpZgJMuXL2fRnYiIiIiIonK73Whvb0dzczMcDgeWLFkCh8OB5uZmtLe3w+12Z/oUiYgojVh0J6KcF+8C12q1oq2tTddzt7W1wWq1puK0iYiIiIgoD7jdbmzYsAGtra2aXHcA2LNnD1pbW7Fx40YW3omIphAW3YkopyWywLVYLFizZg3WrVsX9bnXr1+P1atXcysoERERERGF5fV6sWPHDmzbti3qcVu3bsXOnTvD7sQlIqL8w6I7EeWsZBa4NpsNDz74ILZv3z4paqapqQnbt2/Hli1bYLPZUnHqRERERESUBzweDzZt2qTr2M2bN8Pj8aT4jIiIKBtIsixn+hymBEmS9i9evHjx/v37M30qRHnD7Xbj5ptvxt69e2Meu3z5crz00kuTiuherxcejwculwsulwt2u53DjoiIiIiISBen0wmHw6H7+K6uLtTW1qbwjIiIyAiNjY04cODAAVmWGxN5PCtKRJSzXC6XroI7AOzevRsul2tS0d1iscBiscBms3HxS0REREREcenr64vreJfLxesOIqIpgEV3IspZXOBmJ3H3QF9fHyo
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"trees = [10,50,100]\n",
"for n in trees:\n",
" \n",
" model = RandomForestRegressor(n_estimators=n)\n",
" \n",
" run_model(model,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Gradient Boosting\n",
"\n",
"We will cover this in more detail in next section."
]
},
{
"cell_type": "code",
"execution_count": 291,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.ensemble import GradientBoostingRegressor"
]
},
{
"cell_type": "code",
"execution_count": 292,
"metadata": {},
"outputs": [],
"source": [
"# help(GradientBoostingRegressor)"
]
},
{
"cell_type": "code",
"execution_count": 293,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.13294148649584667\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeVxcd7k/8M+BgQGGwBDIymQnG4SEtE26hCTVWm1tIV3QKl5rG7UJ6q1eTai31+u93t/9WSFxqfdqkvqztW5Y0ZqEqummbUO6xQaSANnIzpAFCBPgAAPDnN8fMGfOwOxzZv+8X6+8mOV7zhzIMHzPc57v8wiSJIGIiIiIiIiIiIiIiAKXEO4DICIiIiIiIiIiIiKKFQy6ExERERERERERERGphEF3IiIiIiIiIiIiIiKVMOhORERERERERERERKQSBt2JiIiIiIiIiIiIiFTCoDsRERERERERERERkUoYdCciIiIiIiIiIiIiUgmD7kREREREREREREREKmHQnYiIiIiIiIiIiIhIJQy6ExERERERERERERGphEF3IiIiIiIiIiIiIiKVMOhORERERERERERERKQSBt2JiIiIiIiIiIiIiFTCoDsRERERERERERERkUqiMuguCEKaIAj3CYLwc0EQTgiCMCgIgigIwmFBEL4tCEK6H/u8UxCEPwuC0CEIwrAgCF2CILwiCML9wfgeiIiIiIiIiIiIiCj2CJIkhfsYfCYIwhcA/Gzs7jEATQAyANwGYBKA4wDWS5J01cv9fQ3ADwFIAN4BcBHALAC3AhAAfFeSpH8L8JgvA0gb2zcRERERERERERERRaZZAPolSZruz8bRGnT/HEYD7D+SJOmY4vEZAP4MYCWAGkmSyr3Y1xSMBsITANwpSdKbiufWAXgFQDKAPEmSzgRwzD1arXbSggUL/N0FEREREREREREREQXZ6dOnYTabeyVJyvBn+6gMursjCMKtAN4GYAaQIUnSkIfx9wKoA/CyJEl3OXl+D4BSAA9JkvT7AI6rOT8/P7+5udnfXRARERERERERERFRkBUUFKClpaVFkqQCf7aPypruHhwe+6oFkO3FeLOX++3y73CIiIiIiIiIiIiIKF7EYtB9/tjXYQDXvBj/PgATgA8LgrBe+cRYeZmPATgFYL+Kx0hEREREREREREREMSgWg+5fHfu6T5Ikj1nskiRdB/B5AFYAfxcEoV4QhN8JglAP4A0ABwF8zFOZGiIiIiIiIiIiIiIiTbgPQE2CIHwcowH0YQD/7u12kiS9KAjC3QB+D2CN4qkejDZSNfpwDK6KtrODKhEREREREREREVGMi5lMd0EQlgD4NQABwFZJkg572ES57TcAvAbgLQDLAaSPff0bgP8C8KLqB0xEREREREREREREMScmMt0FQcgFsA9AFoAfSJL0tA/b3g5gO4BDAD4hSZJ17KmjgiCUAfgHgHsEQbhbkqS/etqfq462Yxnw+d4eFxERERERERERERFFn6jPdBcEYTJGS8DMAfAcgC0+7uKzY1//pAi4AwAkSRqBPct9XSDHSURERERERERERESxL6qD7oIgpAP4K0YzyF8E8EVJkiQfd2MY+3rdxfO2x7N8P0IiIiIiIiIiIiIiiidRG3QXBEELYA+A1QBeBvDpscx0X10e+3qTi+dXjX0958e+iYiIiIiIiIiIiCiORGXQXRCERAA1AD4MYD+AByRJGvKwzVcEQTguCMJT457aPfb1M4Ig3Dtumw0AygFYAfxJjWMnIiIiIiIiIiIiotgVrY1UvwLg/rHbnQB+KgiCs3FbJEnqHLudA2AxgBnjxuwGUAvgEwDqBEH4B4CzAObBnv3+b5IknVDt6ImIiIiIiIiIiIgoJkVr0F1ZX/1+l6OA/8RoUN4lSZIkQRAeArAPwOcALAdQBMAE4C8A/keSpH0BHCsRERERERERERERxQnB976j5A9BEJrz8/Pzm5ubw30oRERERERERERERORCQUEBWlpaWiRJKvBn+6is6U5EREREREREREREFIkYdCciIiIiIiIiIiIiUgmD7kREREREREREREREKmHQnYiIiIiIiIiIiIhIJQy6ExERERERERERERGphEF3IiIiIiIiIiIiIiKVMOhORERERERERERERKQSBt2JiIiIiIiIiIiIiFTCoDsRERERERERERERkUo04T4AIiICLBYLzGYzTCYTuru7kZWVBb1eD61WC42GH9VERERERERERN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cnKQkZGBpKQkBpMVNBqNwwpfIqJYxk9/Ioo7WVlZPo2P16ZHRERERETkmS2YrNVqodfrYTKZcPr0aWRlZTGTm4goTrGmOxHFBIvFAlEUYTQa0dTUBKPRCFEUnTZB1ev1E2oJurJy5UoG3YmIiIiIyC1RFFFbW4vi4mIYDAYUFhbCYDCguLgYtbW1EEUx3IdIREQhxKA7EUU9Xye4Wq0WlZWVXu27srISWq02GIdNREREREQxQBRFbNmyBeXl5Q513QGgsbER5eXl2Lp1KwPvRERxhEF3Iopq/kxwNRoNSktLsXnzZrf7rqioQElJCZeCEhERERGRUxaLBXv37sXOnTvdjtuxYwfq6uqcrsQlIqLYw6A7EUWtQCa4Op0O27dvR01NzYRSM0VFRaipqcG2bdug0+mCcehERERERBQDzGYzqqqqvBpbXV0Ns9kc5CMiIqJIIEiSFO5jiAuCIDTn5+fnNzc3h/tQiGKGKIpYs2YNDh8+7HHsypUrsX///glBdIvFArPZDJPJBJPJBL1ez2ZHRERERETkFaPRCIPB4PX4trY25ObmBvGIiIhIDQUFBWhpaWmRJKnAn+0ZUSKiqGUymbwKuANAQ0MDTCbThKC7RqOBRqOBTqfj5JeIiIiIiHzS3d3t03iTycTzDiKiOMCgOxFFLU5wI5Ny9UB3dzeysrK4eoCIiIiIYlJWVpZP4/V6vaqvz7k3EVFkYk13Iopa4Z7
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
" \n",
"model = GradientBoostingRegressor()\n",
"\n",
"run_model(model,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Adaboost"
]
},
{
"cell_type": "code",
"execution_count": 294,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.ensemble import AdaBoostRegressor"
]
},
{
"cell_type": "code",
"execution_count": 295,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RMSE : 0.13294148649584667\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABd0AAAMGCAYAAAAHgi0pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAABcSAAAXEgFnn9JSAAEAAElEQVR4nOzdeVxcd7k/8M+BgQGGwBDIymQnG4SEtE26hCTVWm1tIV3QKl5rG7UJ6q1eTai31+u93t/9WSFxqfdqkvqztW5Y0ZqEqummbUO6xQaSANnIzpAFCBPgAAPDnN8fMGfOwOxzZv+8X6+8mOV7zhzIMHzPc57v8wiSJIGIiIiIiIiIiIiIiAKXEO4DICIiIiIiIiIiIiKKFQy6ExERERERERERERGphEF3IiIiIiIiIiIiIiKVMOhORERERERERERERKQSBt2JiIiIiIiIiIiIiFTCoDsRERERERERERERkUoYdCciIiIiIiIiIiIiUgmD7kREREREREREREREKmHQnYiIiIiIiIiIiIhIJQy6ExERERERERERERGphEF3IiIiIiIiIiIiIiKVMOhORERERERERERERKQSBt2JiIiIiIiIiIiIiFTCoDsRERERERERERERkUqiMuguCEKaIAj3CYLwc0EQTgiCMCgIgigIwmFBEL4tCEK6H/u8UxCEPwuC0CEIwrAgCF2CILwiCML9wfgeiIiIiIiIiIiIiCj2CJIkhfsYfCYIwhcA/Gzs7jEATQAyANwGYBKA4wDWS5J01cv9fQ3ADwFIAN4BcBHALAC3AhAAfFeSpH8L8JgvA0gb2zcRERERERERERERRaZZAPolSZruz8bRGnT/HEYD7D+SJOmY4vEZAP4MYCWAGkmSyr3Y1xSMBsITANwpSdKbiufWAXgFQDKAPEmSzgRwzD1arXbSggUL/N0FEREREREREREREQXZ6dOnYTabeyVJyvBn+6gMursjCMKtAN4GYAaQIUnSkIfx9wKoA/CyJEl3OXl+D4BSAA9JkvT7AI6rOT8/P7+5udnfXRARERERERERERFRkBUUFKClpaVFkqQCf7aPypruHhwe+6oFkO3FeLOX++3y73CIiIiIiIiIiIiIKF7EYtB9/tjXYQDXvBj/PgATgA8LgrBe+cRYeZmPATgFYL+Kx0hEREREREREREREMSgWg+5fHfu6T5Ikj1nskiRdB/B5AFYAfxcEoV4QhN8JglAP4A0ABwF8zFOZGiIiIiIiIiIiIiIiTbgPQE2CIHwcowH0YQD/7u12kiS9KAjC3QB+D2CN4qkejDZSNfpwDK6KtrODKhEREREREREREVGMi5lMd0EQlgD4NQABwFZJkg572ES57TcAvAbgLQDLAaSPff0bgP8C8KLqB0xEREREREREREREMScmMt0FQcgFsA9AFoAfSJL0tA/b3g5gO4BDAD4hSZJ17KmjgiCUAfgHgHsEQbhbkqS/etqfq462Yxnw+d4eFxERERERERERERFFn6jPdBcEYTJGS8DMAfAcgC0+7uKzY1//pAi4AwAkSRqBPct9XSDHSURERERERERERESxL6qD7oIgpAP4K0YzyF8E8EVJkiQfd2MY+3rdxfO2x7N8P0IiIiIiIiIiIiIiiidRG3QXBEELYA+A1QBeBvDpscx0X10e+3qTi+dXjX0958e+iYiIiIiIiIiIiCiORGXQXRCERAA1AD4MYD+AByRJGvKwzVcEQTguCMJT457aPfb1M4Ig3Dtumw0AygFYAfxJjWMnIiIiIiIiIiIiotgVrY1UvwLg/rHbnQB+KgiCs3FbJEnqHLudA2AxgBnjxuwGUAvgEwDqBEH4B4CzAObBnv3+b5IknVDt6ImIiIiIiIiIiIgoJkVr0F1ZX/1+l6OA/8RoUN4lSZIkQRAeArAPwOcALAdQBMAE4C8A/keSpH0BHCsRERERERERERERxQnB976j5A9BEJrz8/Pzm5ubw30oRERERERERERERORCQUEBWlpaWiRJKvBn+6is6U5EREREREREREREFIkYdCciIiIiIiIiIiIiUgmD7kREREREREREREREKmHQnYiIiIiIiIiIiIhIJQy6ExERERERERERERGphEF3IiIiIiIiIiIiIiKVMOhORERERERERERERKQSBt2JiIiIiIiIiIiIiFTCoDsRERERERERERERkUo04T4AIiICLBYLzGYzTCYTuru7kZWVBb1eD61WC42GH9VERERERERERNGCme5ERGEmiiJqa2tRXFwMg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pfIqJYxk9/Ioo7WVlZPo2P16ZHRERERETkmS2YrNVqodfrYTKZcPr0aWRlZTGTm4goTrGmOxHFBIvFAlEUYTQa0dTUBKPRCFEUnTZB1ev1E2oJurJy5UoG3YmIiIiIyC1RFFFbW4vi4mIYDAYUFhbCYDCguLgYtbW1EEUx3IdIREQhxKA7EUU9Xye4Wq0WlZWVXu27srISWq02GIdNREREREQxQBRFbNmyBeXl5Q513QGgsbER5eXl2Lp1KwPvRERxhEF3Iopq/kxwNRoNSktLsXnzZrf7rqioQElJCZeCEhERERGRUxaLBXv37sXOnTvdjtuxYwfq6uqcrsQlIqLYw6A7EUWtQCa4Op0O27dvR01NzYRSM0VFRaipqcG2bdug0+mCcehERERERBQDzGYzqqqqvBpbXV0Ns9kc5CMiIqJIIEiSFO5jiAuCIDTn5+fnNzc3h/tQiGKGKIpYs2YNDh8+7HHsypUrsX///glBdIvFArPZDJPJBJPJBL1ez2ZHRERERETkFaPRCIPB4PX4trY25ObmBvGIiIhIDQUFBWhpaWmRJKnAn+0ZUSKiqGUymbwKuANAQ0MDTCbThKC7RqOBRqOBTqfj5JeIiIiIiHzS3d3t03iTycTzDiKiOMCgOxFFLU5wI5Ny9UB3dzeysrK4eoCIiIiIYlJWVpZP4/V6vaqvz7k3EVFkYk13Iopa4Z7
"text/plain": [
"<Figure size 1800x900 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"model = GradientBoostingRegressor()\n",
"\n",
"run_model(model,X_train,y_train,X_test,y_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----"
]
}
],
"metadata": {
"anaconda-cloud": {},
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}