{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "ae02d6c8", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from sklearn import linear_model" ] }, { "cell_type": "code", "execution_count": 3, "id": "6729b5ba", "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv(\"housing_price.csv\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "717fda9f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
areaprice
086.45117.0
191.5798.0
285.52114.0
3103.60146.0
4105.25106.0
599.00109.0
687.9591.5
\n", "
" ], "text/plain": [ " area price\n", "0 86.45 117.0\n", "1 91.57 98.0\n", "2 85.52 114.0\n", "3 103.60 146.0\n", "4 105.25 106.0\n", "5 99.00 109.0\n", "6 87.95 91.5" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "code", "execution_count": 5, "id": "8bae038f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjsAAAGwCAYAAABPSaTdAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/NK7nSAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAvn0lEQVR4nO3dfVjUdb7/8dcAiqQyBCYwgohpamlGuhEVpclVaGu26JbGZdaans7J0ujGPP3Ubo/dbanlydOte7WWbR2yPbbZmlbiSqQW282WR40UFHSNANFU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prq7W9u3bPc+LiopUWFio6OhoxcfHa8KECfrss8+0atUq1dXVec7DiY6OVufOnTVo0CBlZmZq2rRpWrp0qWpqajRjxgxNnDix2SuxAADAqaVNYcfhcOjAgQON2isrKz13U26NzZs3a+TIkZ7nDScNT5kyRffff7/+/Oc/S5LOO+88r9d9+OGHGjFihCRp+fLlmjFjhkaNGqWQkBCNHz9eixcvPsEZAQAAWzmMMeZEXzR27FhFRETo9ddf99xBua6uTtddd50OHjyo9957z+eFtqeqqio5nU5VVlZ6nRMEAAACV2s/v9u0Z+exxx7TpZdeqgEDBig9PV2SlJeXp6qqKq1bt65tFQMAALSDNp2gfPbZZ+uLL77Qtddeq3379unAgQO64YYb9O2332rw4MG+rhEAAKDN2nQYyzYcxgIAIPj4/DDWF198ocGDByskJERffPFFi33PPffc1lcKAADQjlodds477zzP1zOcd955cjgcamqnkMPhOKErsgAAANpTq8NOUVGRzjjjDM/fAQAAgkGrw05SUpIk912NH3jgAc2dO1fJycntVhiaUVcn5eVJpaVSfLyUni793+X/AACgsRO+GqtTp0767//+7/aoBceTmyv16SONHCldf737zz593O0AAKBJbbr0/JprrtHKlSt9XApalJsrTZgglZR4t+/e7W4n8AAA0KQ23VSwf//+evDBB/W3v/1Nw4YNU9euXb2W33777T4pDv+nrk6aOVNq6i4BxkgOhzRrljRuHIe0AAD4hTbdZ6elc3UcDoe+++67kyqqowX8fXY++sh9yOp4PvxQ+r/vDAMAwHbt+nURx16N1ZCVHA5HW4ZCa5SW+rYfAACnkDadsyNJL730kgYPHqwuXbqoS5cuGjx4sF588UVf1oYG8fG+7QcAwCmkTXt25s2bp6eeekq33Xab0tLSJEn5+fm64447tGvXLj344IM+LfKUl54uJSS4T0Zu6qijw+Fe/n9fygoAAH7WpnN2zjjjDC1evFiTJk3yan/99dd12223af/+/T4rsCME/Dk70s9XY0negafh8OFbb0lZWR1fFwAAftLaz+82HcaqqanR8OHDG7UPGzZMtbW1bRkSx5OV5Q40vXp5tyckEHQAAGhBm8LO5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Nu3bpp/Pjx2rt3r6+nJ+nk5/j9999r6tSpXr+L58+fr6NHj7b4viNGjGi0Xm+55Zb2mKJP1mOfPn0a1fvoo4+2+L4dth7NKeqRRx4xMTExZtWqVaaoqMi8+eabplu3bmbRokWePlOmTDGZmZmmtLTU8ygvL29x3BUrVpjOnTubl19+2Xz99ddm2rRpJioqyuzdu7e9p9RIa+Z47NxKS0vNyy+/bBwOh9mxY0ez486fP9+cc845Xq/75z//2RFTatK1115rzj77bPPxxx+bbdu2mfnz55vIyEhTUlJijDHm0UcfNU6n06xcudL8/e9/N1dffbVJTk42P/30U7NjBtJ6NKblOVZUVJiMjAzzxhtvmG+//dbk5+ebCy64wAwbNqzFMYNtPQb79tjgePMMtm3yL3/5i7nvvvtMbm6ukWTefvttr+Wt2f4yMzPN0KFDzSeffGLy8vJMv379zKRJk1p831tuucUkJiaatWvXms2bN5sLL7zQXHTRRe0xxZOe43vvvWduvPFG8/7775sdO3aYd955x/Ts2dPceeedLb7vZZddZqZNm+a1XisrKwNyjsYYk5SUZB588EGvequrq1t8345aj6ds2LnqqqvM7373O6+2rKwsk52d7Xk+ZcoUM27cuBMa94ILLjC33nqr53ldXZ1xuVxmwYIFJ1VvW7Rmjr80btw4c/nll7c47vz5883QoUN9UeJJO3TokAkNDTWrVq3yaj///PPNfffdZ+rr601cXJx54oknPMsqKipMeHi4ef3115sdN5DW4/Hm2JRPP/3USDI7d+5sdtxgWo/GBP/2aEzb1mUwbZO//JBszfb3j3/8w0gymzZt8vR57733jMPhMLt3727yfSoqKkynTp3Mm2++6Wn75ptvjCSTn5/v41l5a8scm/L444+b5OTkFt/rsssuMzNnzjzZkk9YW+eYlJRknn766Va/T0eux1P2MNZFF12ktWvX6n//938lSX//+9+1YcMGjR492qvfRx99pJ49e2rAgAH613/9V/3www/Njnn06FFt2bJFGRkZnraQkBBlZGQoPz+/fSbSgtbOscHevXv17rvvaurUqccde9u2bXK5XOrbt6+ys7O1a9cun9beWrW1taqrq1OXLl282iMiI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mr236W9nXnmmfr4449VXV2t4uJiffrpp6qpqVHfvn09/+4nsk4CbT1KLc+xQUPQ2blzp9asWdPiXp2mBPJ6bEqwbY8NWjvPYN4mG7Rm+4uLi9O+ffu8ltfW1qq8vLzZ9RQXF6ejR4+qoqKi2XE7yon8jtmzZ49Gjhypiy66SM8///wJv1dqaqokdfh6bcvvUcldb21trb7//vtmx+2o9XjKhp1Dhw4pJMR7+qGhoaqvr2/2NSUlJfrhhx8UHx/f5PLOnTtr2LBhWrt2raetvr5ea9euVVpamm8KPwEnMseXXnpJw4YN09ChQ0/4faqrq7Vjx45m/106SteuXRUfH68ff/xR77//vsaNG6fk5GTFxcV5rZOqqioVFBQ0u04CbT0eq6k5Sj8HnW3btumDDz5QTEzMCY8dyOuxKcG2Pf7S8eZpwzbZmu0vLS1NFRUVXnu21q1bp/r6es+H+y8NGzZMnTp18hp369at2rVrV4ev29b+jtm9e7dGjBihYcOG6ZVXXmn0u7k1CgsLJanD12tbfo9K7npDQkIaHaZs0KHr0aenOweRKVOmmF69enkuy87NzTU9evQw99xzjzHGmAMHDpi77rrL5Ofnm6KiIvPBBx+Y888/3/Tv398cPnzYM87ll19unnnmGc/zFStWmPDwcLNs2TLzj3/8w0yfPt1ERUWZsrKygJtjg8rKSnPaaaeZ5557rslxfjnHO++803z00UemqKjI/O1vfzMZGRmmR48eZt++fe06n+asXr3avPfee+a7774zf/3rX83QoUNNamqqOXr0qDHGfclkVFSUeeedd8wXX3xhxo0b1+iSyUBej8a0PMejR4+aq6++2iQkJJjCwkKvyz6PHDniGSOY16MN22OD4/28GhNc2+SBAwfM559/bj7//HMjyTz11FPm888/91wJ2JrtLzMz06SkpJiCggKzYcMG079/f69Lz0tKSsyAAQNMQUGBp+2WW24xvXv3NuvWrTObN282aWlpJi0tLSDnWFJSYvr162dGjRplSkpKvLbR5ua4fft28+CDD5rNmzeboqIi884775i+ffuaSy+9NCDnuHHjRvP000+bwsJCs2PHDvPHP/7RnHHGGeaGG25odo7GdNx6PGXDTlVVlZk5c6bp3bu36dKli+nbt6+57777PB8Ohw4dMldccYU544wzTKdOnUxSUpKZNm1ao1+SSUlJZv78+V5tzzzzjOndu7fp3LmzueCCC8wnn3zSUdPycrw5Nviv//ovExERYSoqKpoc55dzvO6660x8fLzp3Lmz6dWrl7nuuuvM9u3b23MqLXrjjTdM3759TefOnU1cXJy59dZbveZSX19v5s6da2JjY014eLgZNWqU2bp1q9cYgbwejWl5jkVFRUZSk48PP/zQM0Ywr0cbtscGx/t5NSa4tskPP/ywyZ+9KVOmGGNat/398MMPZtKkSaZbt24mMjLS3HTTTebAgQOe5Q0/48f+PP/000/m3/7t38zpp59uTjvtNPOb3/zGKzwE0hxfeeWVZrfR5ua4a9cuc+mll5ro6GgTHh5u+vXrZ+6+++52u8/Oyc5xy5YtJjU11TidTtOlSxczaNAg8x//8R9e/xnx53p0GHPM7XQBAAAsc8qeswMAAE4NhB0AAGA1wg4AALAaYQcAAFiNsAMAAKxG2AEAAFYj7AAAAKsRdgAAgNUIOwAAwGqEHQAAYDXCDgBr1dTU+LsEAAGAsAMgaKxevVqXXHKJoqKiFBMTo1//+tfasWOHJOn777+Xw+HQG2+8ocsuu0xdunTR8uXLJUkvvviiBg0apC5dumjgwIH6z//8T69xZ8+erbPOOkunnXaa+vbtq7lz5xKUAIuE+bsAAGitgwcPKicnR+eee66qq6s1b948/eY3v1FhYaGnz7333qvf//73SklJ8QSeefPm6dlnn1VKSoo+//xzTZs2TV27dtWUKVMkSd27d9eyZcvkcrn05Zdfatq0aerevbvuueceP80UgC/xrecAgtb+/ft1xhln6Msvv1S3bt2UnJyshQsXaubMmZ4+/fr100MPPaRJkyZ52h5++GH95S9/0caNG5sc98knn9SKFSu0efPmdp8DgPZH2AEQNLZt26Z58+apoKBA+/fvV319vQ4ePKh3331XZ599tpKTk7VhwwZdfPHFktx7grp166aIiAiFhPx81L62tlZOp1N79+6VJL3xxhtavHixduzYoerqatXW1ioyMlL79u3zyzwB+BaHsQAEjbFjxyopKUkvvPCCXC6X6uvrNXjwYB09etTTp2vXrp6/V1dXS5JeeOEFpaameo0VGhoqScrPz1d2drYeeOABXXnllXI6nVqxYoV+//vfd8CMAHQEwg6AoPDDDz9o69ateuGFF5Seni5J2rBhQ4uviY2Nlcvl0nfffafs7Owm+2zcuFFJSUm67777PG07d+70XeEA/I6wAyAonH766YqJidHzzz+v+Ph47dq1S/fee+9xX/fAAw/o9ttvl9PpVGZmpo4cOaLNmzfrxx9/VE5Ojvr3769du3ZpxYoV+tWvfqV3331Xb7/9dgfMCEBH4dJzAEEhJCREK1as0JYtWzR48GDdcccdeuKJJ477uptvvlkvvviiXnnlFQ0ZMkSXXXaZli1bpuTkZEnS1VdfrTvuuEMzZszQeeedp40bN2ru3LntPR0AHYgTlAEAgNXYswMAAKxG2AEAAFYj7AAAAKsRdgAAgNUIOwAAwGqEHQAAYDXCDgAAsBphBwAAWI2wAwAArEbYAQAAViPsAAAAq/1/1kjtfYKMMJsAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%matplotlib inline\n", "plt.xlabel(\"area\")\n", "plt.ylabel(\"price\")\n", "plt.scatter(df.area, df.price, c='r')" ] }, { "cell_type": "code", "execution_count": 6, "id": "1dbdd68d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(7, 1)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[[\"area\"]].shape" ] }, { "cell_type": "code", "execution_count": 7, "id": "c147b635", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "LinearRegression()" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model = linear_model.LinearRegression()\n", "model.fit(df[[\"area\"]].values, df.price.values)" ] }, { "cell_type": "code", "execution_count": 8, "id": "cd1a7008", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([0.83809367]), 32.70161672527138)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.coef_, model.intercept_" ] }, { "cell_type": "code", "execution_count": 9, "id": "d7e74d63", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([115.93269948])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.predict(np.array([[99.31]]))" ] }, { "cell_type": "code", "execution_count": 10, "id": "4fffcc21", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([115.93269948])" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "price = model.coef_ * 99.31 + model.intercept_\n", "price" ] }, { "cell_type": "markdown", "id": "1859e8a2", "metadata": {}, "source": [ "## 保存模型" ] }, { "cell_type": "code", "execution_count": 14, "id": "e29158e1", "metadata": {}, "outputs": [], "source": [ "import pickle" ] }, { "cell_type": "code", "execution_count": null, "id": "757f7233", "metadata": {}, "outputs": [], "source": [ "with open(\"linear_model.pkl\")" ] } ], "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.7.9" } }, "nbformat": 4, "nbformat_minor": 5 }