320 lines
94 KiB
Plaintext
320 lines
94 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 125,
|
||
|
"id": "366a3913",
|
||
|
"metadata": {
|
||
|
"pycharm": {
|
||
|
"is_executing": true
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import ipywidgets as widgets\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import numpy as np\n",
|
||
|
"import pandas as pd\n",
|
||
|
"from sklearn.linear_model import LinearRegression\n",
|
||
|
"from sklearn.preprocessing import PolynomialFeatures\n",
|
||
|
"\n",
|
||
|
"%matplotlib inline\n",
|
||
|
"%reload_ext autoreload\n",
|
||
|
"%autoreload 2"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 126,
|
||
|
"id": "b76f2b19",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"data = pd.read_csv('data6.tsv',sep='\\t',names=['x','y'])\n",
|
||
|
"data = data.sort_values(by=['x'])\n",
|
||
|
"# data_x = pd.DataFrame(data['x'])\n",
|
||
|
"# data_y = pd.DataFrame(data['y'])\n",
|
||
|
"# data_x = data['x'].array.reshape(-1,1)\n",
|
||
|
"# data_y = data['y'].array.reshape(-1,1)\n",
|
||
|
"data_x = data['x']\n",
|
||
|
"data_y = data['y']"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 127,
|
||
|
"id": "650769e3",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.collections.PathCollection at 0x7f7a01580610>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 127,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAAN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9ofiWnLGKmqyl8HP4IMAAAxoqYmsnX9AUEGAIAYkZYW2br+gCADAECMyMry351ks3W83WaTMjL8dfAjyAAAECPi4/23WEvtw0zr861bmU+mLYIMAAAxJD9f2rNHGjMmuN3p9Lczj0wwJsQDACDG5OdLeXnRm9nXSrMKE2QAAIhB8fHSnDm9/32tNqswp5YAAIAka84qTJABAACWnVWYIAMAACw7qzBBBgAAWHZWYYIMAACw7KzCBBkAAGDZWYUJMgAAwLKzChNkAACAJGvOKsyEeAAAICDaswqHiyADAACCRGtW4a7g1BIAALAsggwAALAsTi0BANAFVlohui8jyAAAECarrRDdl3FqCQCAMFhxhei+jCADAECIrLpCdF9GkAEAIERWXSG6LyPIAAAQIquuEN2XEWQAAAiRVVeI7ssIMgAAhMiqK0T3ZQQZAABCZNUVovsyggwAAGGw4grRfRkT4gEAECarrRDdlxFkAADoAiutEN2XEWQAAAgT6yzFDoIMAABhYJ2l2MLFvgAAhKi31lny+aSjR6WXXvL/y5IH344gAwBACHprnSWXSxo/Xpo7V7rnHv+/48ezGOW3IcgAABCC3lhniZW1w0eQAQAgBD29zhIra3cNQQYAgBD09DpLrKzdNQQZAABC0NPrLLGydtcQZAAACEFPr7PEytpdQ5ABACBEPbnOEitrdw0T4gEAEIaeWmep9YjP4sX+0NL2ol9W1v52BBkAAMLUU+sstR7x6Wjm4K1bmTm4IwQZAABiCCtrh4cgAwBAjGFl7dBxsS8AALAsggwAALAsggwAALAsggwAALAsggwAALAsggwAALAsggwAALAsggwAALAsggwAALAsggwAALAsggwAALAsggwAALCssILM9u3bNX36dDkcDjkcDmVmZurAgQOB7VevXlVBQYFGjhypYcOGadGiRaqtrQ16j8rKSuXm5mrIkCFKTk7WunXrdO3ataCao0ePaubMmbLb7Zo4caJ27tzZ9RECAIA+K6wg43Q6tWnTJpWVlemdd97RD3/4Q+Xl5en8+fOSpDVr1uiNN97Q7t27dezYMVVXVys/Pz/wep/Pp9zcXDU1NenkyZPatWuXdu7cqQ0bNgRqLly4oNzcXM2dO1fl5eUqKirSihUrdPDgwQgNGQAA9BU2Y4zpzhuMGDFCW7Zs0eLFizV69Gi9+OKLWrx4sSTpww8/1C233KLS0lLdfvvtOnDggH784x+rurpaKSkpkqQdO3Zo/fr1+vzzz5WQkKD169dr//79OnfuXOB73HXXXaqvr9dbb70Vcr+8Xq8SExPl8XjkcDi6M0QAANBLwv387vI1Mj6fTy+//LIuX76szMxMlZWVqbm5WdnZ2YGayZMna+zYsSotLZUklZaWatq0aYEQI0k5OTnyer2BozqlpaVB79Fa0/oe36axsVFerzfoAQAA+rawg8zZs2c1bNgw2e12rVy5Unv37tWUKVPkdruVkJCgpKSkoPqUlBS53W5JktvtDgoxrdtbt12vxuv16sqVK9/ar40bNyoxMTHwyMjICHdoAADAYsIOMpMmTVJ5eblOnTqlVatWadmyZfrggw96om9hKS4ulsfjCTyqqqqi3SUAANDDBoT7goSEBE2cOFGSNGvWLJ05c0bbtm3TkiVL1NTUpPr6+qCjMrW1tUpNTZUkpaam6vTp00Hv13pXU9uab97pVFtbK4fDocGDB39rv+x2u+x2e7jDAQAAFtbteWRaWlrU2NioWbNmaeDAgTp06FBgW0VFhSorK5WZmSlJyszM1NmzZ1VXVxeoKSkpkcPh0JQpUwI1bd+jtab1PQAAAFqFdUSmuLhYCxcu1NixY9XQ0KAXX3x
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.scatter(data_x,data_y,color='blue')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 128,
|
||
|
"id": "6bdbfb22",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"8 12.390\n",
|
||
|
"19 12.424\n",
|
||
|
"0 21.252\n",
|
||
|
"11 63.254\n",
|
||
|
"13 71.108\n",
|
||
|
"12 72.439\n",
|
||
|
"5 87.624\n",
|
||
|
"16 99.073\n",
|
||
|
"3 114.269\n",
|
||
|
"2 118.162\n",
|
||
|
"4 121.444\n",
|
||
|
"18 131.023\n",
|
||
|
"9 144.264\n",
|
||
|
"15 169.084\n",
|
||
|
"10 169.900\n",
|
||
|
"6 170.039\n",
|
||
|
"14 179.476\n",
|
||
|
"1 179.842\n",
|
||
|
"7 192.651\n",
|
||
|
"17 195.528\n",
|
||
|
"Name: x, dtype: float64"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 128,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"data_x"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 129,
|
||
|
"id": "392159c0",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.collections.PathCollection at 0x7f7a01573a30>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 129,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAGdCAYAAAAIbpn/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAABHRElEQVR4nO3de1yUZf7/8deAgpgCeQIUTK02M0VTy9jCNE3ya2VLtlau2snSrCTbMve7a4dtV1c7aKV2NC3b2lRsS83Wcx5YDxipbfJr01Y0wK/uApqKOFy/P65lchSFQZh7Bt7Px2Mect9zMXzuRpl3130dXMYYg4iIiEgQCnG6ABEREZGqUpARERGRoKUgIyIiIkFLQUZERESCloKMiIiIBC0FGREREQlaCjIiIiIStBRkREREJGjVc7qAmlJaWsoPP/xA48aNcblcTpcjIiIilWCM4dChQ7Rs2ZKQkIr7W2ptkPnhhx9ISEhwugwRERGpgpycHOLj4ytsV2uDTOPGjQH7HyIyMtLhakRERKQyioqKSEhI8HyOV6TWBpmy20mRkZEKMiIiIkGmssNCNNhXREREgpaCjIiIiAQtBRkREREJWgoyIiIiErQUZERERCRoKciIiIhI0FKQERERkaClICMiIiJBq9YuiCciIiLVz+2GtWshNxfi4iA5GUJDnatHQUZEREQqJT0dxoyBvXt/OhcfD9OmQWqqMzXp1pKIiIhUKD0dBg3yDjEA+/bZ8+npztSlICMiIiJn5XbbnhhjTn+u7Fxamm3nbwoyIiIiclZr157eE3MyYyAnx7bzNwUZEREROavc3OptV53OKchMmjQJl8tFWlqa59yxY8cYPXo0TZs2pVGjRtx6663k5+d7fd+ePXsYMGAADRs2pEWLFjz++OOcOHHCq83q1avp2rUr4eHhXHTRRcyePftcShUREZEqiour3nbVqcpBZvPmzbz++uskJiZ6nX/00Uf59NNPmTdvHmvWrOGHH34g9aShzG63mwEDBnD8+HE2bNjAnDlzmD17NhMmTPC02b17NwMGDKB3795kZWWRlpbGfffdx+eff17VckVERKSKkpPt7CSXq/znXS5ISLDt/M5UwaFDh8zFF19sli1bZq699lozZswYY4wxBQUFpn79+mbevHmett98840BTEZGhjHGmCVLlpiQkBCTl5fnaTNz5kwTGRlpiouLjTHGPPHEE+ayyy7z+pmDBw82KSkpla6xsLDQAKawsLAqlygiIiInWbDAGJfLPuyoGPsoO7dgQfX8HF8/v6vUIzN69GgGDBhA3759vc5nZmZSUlLidb59+/a0bt2ajIwMADIyMujUqRMxMTGeNikpKRQVFfH111972pz62ikpKZ7XKE9xcTFFRUVeDxEREakeqakwfz60auV9Pj7enndqHRmfF8T78MMP2bp1K5s3bz7tuby8PMLCwoiOjvY6HxMTQ15enqfNySGm7Pmy587WpqioiKNHjxIREXHaz544cSLPPPOMr5cjIiIilZSaCgMHBvHKvjk5OYwZM4Z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F/ShSvYQpd3x5L+sT62T6X/IiIiIpVQ0/ssud0w74HlbKMTv+J93ITwB35DDzayg45AgO2sHSAUZERERCqhRvdZOnKE3Nse4YMD15PAXr7lIq5mPb/lD5QQBgTQztoBRkFGRESkEsr2WTp1a4IyLhckJFRhn6XNm6FrV+IXvgLADEbRhSw2clW5zR3dWTsAKciIiIhUQrXvs1RSAk8/DUlJkJ1NcdM4UljKaGZwhPPO+G2O7awdoBRkREREKqna9lnauRN+/nN45hk76OX226n3zQ7+EZ9S/T0+tZzWkREREfHBOe2
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"reg = LinearRegression()\n",
|
||
|
"reg.fit(data_x.array.reshape(-1,1),data_y.array.reshape(-1,1))\n",
|
||
|
"predict_data_y = reg.predict(data_x.array.reshape(-1,1))\n",
|
||
|
"plt.plot(data_x,predict_data_y,color='red')\n",
|
||
|
"plt.scatter(data_x,data_y,color='blue')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 130,
|
||
|
"id": "44f292f4",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"array([[1.23900000e+01, 1.53512100e+02],\n",
|
||
|
" [1.24240000e+01, 1.54355776e+02],\n",
|
||
|
" [2.12520000e+01, 4.51647504e+02],\n",
|
||
|
" [6.32540000e+01, 4.00106852e+03],\n",
|
||
|
" [7.11080000e+01, 5.05634766e+03],\n",
|
||
|
" [7.24390000e+01, 5.24740872e+03],\n",
|
||
|
" [8.76240000e+01, 7.67796538e+03],\n",
|
||
|
" [9.90730000e+01, 9.81545933e+03],\n",
|
||
|
" [1.14269000e+02, 1.30574044e+04],\n",
|
||
|
" [1.18162000e+02, 1.39622582e+04],\n",
|
||
|
" [1.21444000e+02, 1.47486451e+04],\n",
|
||
|
" [1.31023000e+02, 1.71670265e+04],\n",
|
||
|
" [1.44264000e+02, 2.08121017e+04],\n",
|
||
|
" [1.69084000e+02, 2.85893991e+04],\n",
|
||
|
" [1.69900000e+02, 2.88660100e+04],\n",
|
||
|
" [1.70039000e+02, 2.89132615e+04],\n",
|
||
|
" [1.79476000e+02, 3.22116346e+04],\n",
|
||
|
" [1.79842000e+02, 3.23431450e+04],\n",
|
||
|
" [1.92651000e+02, 3.71144078e+04],\n",
|
||
|
" [1.95528000e+02, 3.82311988e+04]])"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 130,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"poly = PolynomialFeatures(degree=2,include_bias=False)\n",
|
||
|
"poly_features = poly.fit_transform(data_x.array.reshape(-1,1))\n",
|
||
|
"poly_features"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 131,
|
||
|
"id": "be4172cb",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"array([-202.19762153, -201.84331399, -104.38856598, 508.27954418,\n",
|
||
|
" 650.17014568, 675.06921604, 976.63832627, 1225.29257965,\n",
|
||
|
" 1583.58306598, 1680.55826071, 1763.95676717, 2015.96524541,\n",
|
||
|
" 2385.40255276, 3143.8333219 , 3170.22794171, 3174.73334816,\n",
|
||
|
" 3486.92151338, 3499.27966172, 3943.55854171, 4046.49646908])"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 131,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"poly_reg = LinearRegression()\n",
|
||
|
"poly_reg.fit(poly_features,data_y)\n",
|
||
|
"y_predicted = poly_reg.predict(poly_features)\n",
|
||
|
"y_predicted"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 132,
|
||
|
"id": "f455e240",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7f7a014e55b0>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 132,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAGdCAYAAAAIbpn/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAABGEElEQVR4nO3deXiU1f3//1cSkrAm7EkgAcEFRUBEKY0WFaFGpIoGFBGVCm4YKIsFxV/FpQsU/Sq4oXUBrAsKBBdEMOwIERHIBwRN1YIgJEHRLLKELOf3x2mGDASSSSZzz0yej+vKBXPPyeR9O8C8vO9zzjvEGGMEAAAQgEKdLgAAAKC6CDIAACBgEWQAAEDAIsgAAICARZABAAABiyADAAACFkEGAAAELIIMAAAIWPWcLqC2lJaWav/+/WrSpIlCQkKcLgcAAFSBMUYFBQVq06aNQkMrv94StEFm//79SkhIcLoMAABQDXv37lV8fHyl44I2yDRp0kSS/Q8RFRXlcDUAAKAq8vPzlZCQ4Pocr0zQBpmy20lRUVEEGQAAAkxVp4Uw2RcAAAQsggwAAAhYBBkAABCwCDIAACBgEWQAAEDAIsgAAICARZABAAABiyADAAACVtBuiAcAALyvpERat07KypLi4qTevaWwMOfqIcgAAIAqSU2Vxo6Vfvjh+LH4eGnmTCk52ZmauLUEAAAqlZoqDR7sHmIkad8+ezw11Zm6CDIAAOC0SkrslRhjTn6u7Ni4cXacrxFkAADAaa1bd/KVmPKMkfbuteN8jSADAABOKyvL/XE9FamnPq90nC/UKMhMmzZNIS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 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.scatter(data_x,data_y,color='blue')\n",
|
||
|
"plt.plot(data_x,y_predicted,color='red')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 133,
|
||
|
"id": "3d3da8ad",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7f7a01449a90>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 133,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAGdCAYAAAAIbpn/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAABIlElEQVR4nO3df3zO9f7H8cdlbH5ufmXD5kfpl59FHWeniJKRSk0lqSSlhCyi41R0nE6KCv2iX+KcSqEhVJLfZQfJSipfSRHbdGibX/the3//eJ9duRjbtV3b57quPe+323Wzz+d677pen3PF9Tzvz/uHyxhjEBEREQlAlZwuQERERKSkFGREREQkYCnIiIiISMBSkBEREZGApSAjIiIiAUtBRkRERAKWgoyIiIgELAUZERERCViVnS6grOTn57Nv3z5q1aqFy+VyuhwREREpBmMMhw4dolGjRlSqVHR/S9AGmX379hETE+N0GSIiIlICe/bsITo6ush2QRtkatWqBdj/IcLDwx2uRkRERIojMzOTmJgY9/d4UYI2yBTcTgoPD1eQERERCTDFHRaiwb4iIiISsBRkREREJGApyIiIiEjAUpARERGRgKUgIyIiIgFLQUZEREQCloKMiIiIBCwFGREREQlYQbsgnoiIiPheXh6sWwcpKdCwIXTqBCEhztWjICMiIiLFkpgII0bAr7/+cS46GqZNg/h4Z2rSrSUREREpUmIi3HSTZ4gB2LvXnk9MdKYuBRkRERE5o7w82xNjzKnPFZxLSLDtypuCjIiIiJzRunWn9sScyBjYs8e2K28KMiIiInJGKSm+bedLpQoyTz/9NC6Xi4SEBPe5rKwshg4dSr169ahZsyZ9+vQhLS3N4/d2795Nr169qF69Og0aNGD06NEcP37co83q1atp3749YWFhtGjRglmzZpWmVBERESmhhg19286XShxkNm3axKuvvkrbtm09zj/00EMsXryYefPmsWbNGvbt20f8CUOZ8/Ly6NWrFzk5Oaxfv57Zs2cza9Ysxo0b526za9cuevXqRdeuXUlOTiYhIYF77rmHZcuWlbRcERERKaFOnezsJJer8OddLoiJse3KnSmBQ4cOmXPPPdcsX77cXHHFFWbEiBHGGGPS09NNlSpVzLx589xtv//+ewOYpKQkY4wxH330kalUqZJJTU11t5k+fboJDw832dnZxhhjxowZY1q1auXxnn379jVxcXHFrjEjI8MAJiMjoySXKCIiIif44ANjXC77sKNi7KPg3Acf+OZ9vP3+LlGPzNChQ+nVqxfdunXzOL9582Zyc3M9zl9wwQU0adKEpKQkAJKSkmjTpg2RkZHuNnFxcWRmZrJt2zZ3m5NfOy4uzv0ahcnOziYzM9PjISIiIr4RHw/z50Pjxp7no6PteafWkfF6Qbz33nuPr776ik2bNp3yXGpqKqGhodSuXdvjfGRkJKmpqe42J4aYgucLnjtTm8zMTI4dO0a1atVOee+JEyfy97//3dvLERERkWKKj4fevQN4Zd89e/YwYsQIli9fTtWqVcuqphIZO3YsI0eOdB9nZmYSExPjYEUiIiLBJyQEunRxuoo/eHVrafPmzezfv5/27dtTuXJlKleuzJo1a3jhhReoXLkykZGR5OTkkJ6e7vF7aWlpREVFARAVFXXKLKaC46LahIeHF9obAxAWFkZ4eLjHQ0RERIKbV0HmqquuYuvWrSQnJ7sfl1xyCf3793f/XKVKFVasWOH+ne3bt7N7925iY2MBiI2NZevWrezfv9/dZvny5YSHh9OyZUt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83owwyCjIiIiLFUOJ9lvLzYfBg+Pe/7S7Wc+faKdeFKLedtYOIgoyIiEgxlGifJWNg2DC
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"poly = PolynomialFeatures(degree=5,include_bias=False)\n",
|
||
|
"poly_features = poly.fit_transform(data_x.array.reshape(-1,1))\n",
|
||
|
"poly_reg = LinearRegression()\n",
|
||
|
"poly_reg.fit(poly_features,data_y)\n",
|
||
|
"y_predicted = poly_reg.predict(poly_features)\n",
|
||
|
"plt.scatter(data_x,data_y,color='blue')\n",
|
||
|
"plt.plot(data_x,y_predicted,color='red')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "efc0facf",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"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.10"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|