mirror of
https://github.com/deepseek-ai/DeepSeek-Coder.git
synced 2025-02-23 14:19:09 -05:00
1508 lines
91 KiB
Plaintext
1508 lines
91 KiB
Plaintext
|
{
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 0,
|
|||
|
"metadata": {
|
|||
|
"colab": {
|
|||
|
"provenance": [],
|
|||
|
"include_colab_link": true
|
|||
|
},
|
|||
|
"kernelspec": {
|
|||
|
"name": "python3",
|
|||
|
"display_name": "Python 3"
|
|||
|
},
|
|||
|
"language_info": {
|
|||
|
"name": "python"
|
|||
|
}
|
|||
|
},
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "view-in-github",
|
|||
|
"colab_type": "text"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"<a href=\"https://colab.research.google.com/github/Orrm23/DeepSeek-Coder/blob/main/11___House_price_prediction_using_Linear_Regression.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "I1VRs4tZkbvW"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"# **Day-11 | House price prediction using Linear Regression-SingleVariable**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "SAFLqwkKk8rK"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### *Import Libraries*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "EgF2lvr_jzVL"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"from sklearn.linear_model import LinearRegression\n",
|
|||
|
"import matplotlib.pyplot as plt"
|
|||
|
],
|
|||
|
"execution_count": 1,
|
|||
|
"outputs": []
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "XWe_7j6UjxRj"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### *Load Dataset from Local Directory*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "vKrHCJk_jwfJ",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 73
|
|||
|
},
|
|||
|
"outputId": "715c67be-afd2-4b0d-c041-a7d3888a5095"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"from google.colab import files\n",
|
|||
|
"uploaded = files.upload()"
|
|||
|
],
|
|||
|
"execution_count": 2,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "display_data",
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"<IPython.core.display.HTML object>"
|
|||
|
],
|
|||
|
"text/html": [
|
|||
|
"\n",
|
|||
|
" <input type=\"file\" id=\"files-ba700bc1-a24e-4d7e-a8ba-3d9c6afc4d6b\" name=\"files[]\" multiple disabled\n",
|
|||
|
" style=\"border:none\" />\n",
|
|||
|
" <output id=\"result-ba700bc1-a24e-4d7e-a8ba-3d9c6afc4d6b\">\n",
|
|||
|
" Upload widget is only available when the cell has been executed in the\n",
|
|||
|
" current browser session. Please rerun this cell to enable.\n",
|
|||
|
" </output>\n",
|
|||
|
" <script>// Copyright 2017 Google LLC\n",
|
|||
|
"//\n",
|
|||
|
"// Licensed under the Apache License, Version 2.0 (the \"License\");\n",
|
|||
|
"// you may not use this file except in compliance with the License.\n",
|
|||
|
"// You may obtain a copy of the License at\n",
|
|||
|
"//\n",
|
|||
|
"// http://www.apache.org/licenses/LICENSE-2.0\n",
|
|||
|
"//\n",
|
|||
|
"// Unless required by applicable law or agreed to in writing, software\n",
|
|||
|
"// distributed under the License is distributed on an \"AS IS\" BASIS,\n",
|
|||
|
"// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
|
|||
|
"// See the License for the specific language governing permissions and\n",
|
|||
|
"// limitations under the License.\n",
|
|||
|
"\n",
|
|||
|
"/**\n",
|
|||
|
" * @fileoverview Helpers for google.colab Python module.\n",
|
|||
|
" */\n",
|
|||
|
"(function(scope) {\n",
|
|||
|
"function span(text, styleAttributes = {}) {\n",
|
|||
|
" const element = document.createElement('span');\n",
|
|||
|
" element.textContent = text;\n",
|
|||
|
" for (const key of Object.keys(styleAttributes)) {\n",
|
|||
|
" element.style[key] = styleAttributes[key];\n",
|
|||
|
" }\n",
|
|||
|
" return element;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"// Max number of bytes which will be uploaded at a time.\n",
|
|||
|
"const MAX_PAYLOAD_SIZE = 100 * 1024;\n",
|
|||
|
"\n",
|
|||
|
"function _uploadFiles(inputId, outputId) {\n",
|
|||
|
" const steps = uploadFilesStep(inputId, outputId);\n",
|
|||
|
" const outputElement = document.getElementById(outputId);\n",
|
|||
|
" // Cache steps on the outputElement to make it available for the next call\n",
|
|||
|
" // to uploadFilesContinue from Python.\n",
|
|||
|
" outputElement.steps = steps;\n",
|
|||
|
"\n",
|
|||
|
" return _uploadFilesContinue(outputId);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"// This is roughly an async generator (not supported in the browser yet),\n",
|
|||
|
"// where there are multiple asynchronous steps and the Python side is going\n",
|
|||
|
"// to poll for completion of each step.\n",
|
|||
|
"// This uses a Promise to block the python side on completion of each step,\n",
|
|||
|
"// then passes the result of the previous step as the input to the next step.\n",
|
|||
|
"function _uploadFilesContinue(outputId) {\n",
|
|||
|
" const outputElement = document.getElementById(outputId);\n",
|
|||
|
" const steps = outputElement.steps;\n",
|
|||
|
"\n",
|
|||
|
" const next = steps.next(outputElement.lastPromiseValue);\n",
|
|||
|
" return Promise.resolve(next.value.promise).then((value) => {\n",
|
|||
|
" // Cache the last promise value to make it available to the next\n",
|
|||
|
" // step of the generator.\n",
|
|||
|
" outputElement.lastPromiseValue = value;\n",
|
|||
|
" return next.value.response;\n",
|
|||
|
" });\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/**\n",
|
|||
|
" * Generator function which is called between each async step of the upload\n",
|
|||
|
" * process.\n",
|
|||
|
" * @param {string} inputId Element ID of the input file picker element.\n",
|
|||
|
" * @param {string} outputId Element ID of the output display.\n",
|
|||
|
" * @return {!Iterable<!Object>} Iterable of next steps.\n",
|
|||
|
" */\n",
|
|||
|
"function* uploadFilesStep(inputId, outputId) {\n",
|
|||
|
" const inputElement = document.getElementById(inputId);\n",
|
|||
|
" inputElement.disabled = false;\n",
|
|||
|
"\n",
|
|||
|
" const outputElement = document.getElementById(outputId);\n",
|
|||
|
" outputElement.innerHTML = '';\n",
|
|||
|
"\n",
|
|||
|
" const pickedPromise = new Promise((resolve) => {\n",
|
|||
|
" inputElement.addEventListener('change', (e) => {\n",
|
|||
|
" resolve(e.target.files);\n",
|
|||
|
" });\n",
|
|||
|
" });\n",
|
|||
|
"\n",
|
|||
|
" const cancel = document.createElement('button');\n",
|
|||
|
" inputElement.parentElement.appendChild(cancel);\n",
|
|||
|
" cancel.textContent = 'Cancel upload';\n",
|
|||
|
" const cancelPromise = new Promise((resolve) => {\n",
|
|||
|
" cancel.onclick = () => {\n",
|
|||
|
" resolve(null);\n",
|
|||
|
" };\n",
|
|||
|
" });\n",
|
|||
|
"\n",
|
|||
|
" // Wait for the user to pick the files.\n",
|
|||
|
" const files = yield {\n",
|
|||
|
" promise: Promise.race([pickedPromise, cancelPromise]),\n",
|
|||
|
" response: {\n",
|
|||
|
" action: 'starting',\n",
|
|||
|
" }\n",
|
|||
|
" };\n",
|
|||
|
"\n",
|
|||
|
" cancel.remove();\n",
|
|||
|
"\n",
|
|||
|
" // Disable the input element since further picks are not allowed.\n",
|
|||
|
" inputElement.disabled = true;\n",
|
|||
|
"\n",
|
|||
|
" if (!files) {\n",
|
|||
|
" return {\n",
|
|||
|
" response: {\n",
|
|||
|
" action: 'complete',\n",
|
|||
|
" }\n",
|
|||
|
" };\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" for (const file of files) {\n",
|
|||
|
" const li = document.createElement('li');\n",
|
|||
|
" li.append(span(file.name, {fontWeight: 'bold'}));\n",
|
|||
|
" li.append(span(\n",
|
|||
|
" `(${file.type || 'n/a'}) - ${file.size} bytes, ` +\n",
|
|||
|
" `last modified: ${\n",
|
|||
|
" file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() :\n",
|
|||
|
" 'n/a'} - `));\n",
|
|||
|
" const percent = span('0% done');\n",
|
|||
|
" li.appendChild(percent);\n",
|
|||
|
"\n",
|
|||
|
" outputElement.appendChild(li);\n",
|
|||
|
"\n",
|
|||
|
" const fileDataPromise = new Promise((resolve) => {\n",
|
|||
|
" const reader = new FileReader();\n",
|
|||
|
" reader.onload = (e) => {\n",
|
|||
|
" resolve(e.target.result);\n",
|
|||
|
" };\n",
|
|||
|
" reader.readAsArrayBuffer(file);\n",
|
|||
|
" });\n",
|
|||
|
" // Wait for the data to be ready.\n",
|
|||
|
" let fileData = yield {\n",
|
|||
|
" promise: fileDataPromise,\n",
|
|||
|
" response: {\n",
|
|||
|
" action: 'continue',\n",
|
|||
|
" }\n",
|
|||
|
" };\n",
|
|||
|
"\n",
|
|||
|
" // Use a chunked sending to avoid message size limits. See b/62115660.\n",
|
|||
|
" let position = 0;\n",
|
|||
|
" do {\n",
|
|||
|
" const length = Math.min(fileData.byteLength - position, MAX_PAYLOAD_SIZE);\n",
|
|||
|
" const chunk = new Uint8Array(fileData, position, length);\n",
|
|||
|
" position += length;\n",
|
|||
|
"\n",
|
|||
|
" const base64 = btoa(String.fromCharCode.apply(null, chunk));\n",
|
|||
|
" yield {\n",
|
|||
|
" response: {\n",
|
|||
|
" action: 'append',\n",
|
|||
|
" file: file.name,\n",
|
|||
|
" data: base64,\n",
|
|||
|
" },\n",
|
|||
|
" };\n",
|
|||
|
"\n",
|
|||
|
" let percentDone = fileData.byteLength === 0 ?\n",
|
|||
|
" 100 :\n",
|
|||
|
" Math.round((position / fileData.byteLength) * 100);\n",
|
|||
|
" percent.textContent = `${percentDone}% done`;\n",
|
|||
|
"\n",
|
|||
|
" } while (position < fileData.byteLength);\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" // All done.\n",
|
|||
|
" yield {\n",
|
|||
|
" response: {\n",
|
|||
|
" action: 'complete',\n",
|
|||
|
" }\n",
|
|||
|
" };\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"scope.google = scope.google || {};\n",
|
|||
|
"scope.google.colab = scope.google.colab || {};\n",
|
|||
|
"scope.google.colab._files = {\n",
|
|||
|
" _uploadFiles,\n",
|
|||
|
" _uploadFilesContinue,\n",
|
|||
|
"};\n",
|
|||
|
"})(self);\n",
|
|||
|
"</script> "
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {}
|
|||
|
},
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"name": "stdout",
|
|||
|
"text": [
|
|||
|
"Saving dataset.csv to dataset.csv\n"
|
|||
|
]
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "6gXowmSom462"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### *Load Dataset*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "6JLDHSdym6wP"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"dataset = pd.read_csv('dataset.csv')"
|
|||
|
],
|
|||
|
"execution_count": 3,
|
|||
|
"outputs": []
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "-DdkIy1ZnDfA"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### *Load Summarize*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "OlElQViRnGFp",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/"
|
|||
|
},
|
|||
|
"outputId": "d47549da-8c94-4e4b-ef5c-d76fae7a04d8"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"print(dataset.shape)\n",
|
|||
|
"print(dataset.head(5))"
|
|||
|
],
|
|||
|
"execution_count": 4,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"name": "stdout",
|
|||
|
"text": [
|
|||
|
"(1460, 2)\n",
|
|||
|
" area price\n",
|
|||
|
"0 8450 208500\n",
|
|||
|
"1 9600 181500\n",
|
|||
|
"2 11250 223500\n",
|
|||
|
"3 9550 140000\n",
|
|||
|
"4 14260 250000\n"
|
|||
|
]
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "p5yk_BN4nMtD"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### *Visualize Dataset*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "a8Mi5nkFnOTQ",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 466
|
|||
|
},
|
|||
|
"outputId": "cb410515-c01a-4870-f356-77eef2cedaa8"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"plt.xlabel('Area')\n",
|
|||
|
"plt.ylabel('Price')\n",
|
|||
|
"plt.scatter(dataset.area,dataset.price,color='red',marker='*')"
|
|||
|
],
|
|||
|
"execution_count": 5,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "execute_result",
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"<matplotlib.collections.PathCollection at 0x7bfbb6e1f010>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"execution_count": 5
|
|||
|
},
|
|||
|
{
|
|||
|
"output_type": "display_data",
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
],
|
|||
|
"image/png": "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
|
|||
|
},
|
|||
|
"metadata": {}
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "JRyfB6prpJDP"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### *Segregate Dataset into Input X & Output Y*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "x9dQcTohpK1X",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 424
|
|||
|
},
|
|||
|
"outputId": "f42cd163-c1ad-4279-da9b-845cd0644611"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"X = dataset.drop('price',axis='columns')\n",
|
|||
|
"X"
|
|||
|
],
|
|||
|
"execution_count": 6,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "execute_result",
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
" area\n",
|
|||
|
"0 8450\n",
|
|||
|
"1 9600\n",
|
|||
|
"2 11250\n",
|
|||
|
"3 9550\n",
|
|||
|
"4 14260\n",
|
|||
|
"... ...\n",
|
|||
|
"1455 7917\n",
|
|||
|
"1456 13175\n",
|
|||
|
"1457 9042\n",
|
|||
|
"1458 9717\n",
|
|||
|
"1459 9937\n",
|
|||
|
"\n",
|
|||
|
"[1460 rows x 1 columns]"
|
|||
|
],
|
|||
|
"text/html": [
|
|||
|
"\n",
|
|||
|
" <div id=\"df-82d1ac63-2545-4535-aa62-9486fd03f7e1\" class=\"colab-df-container\">\n",
|
|||
|
" <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>area</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>0</th>\n",
|
|||
|
" <td>8450</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1</th>\n",
|
|||
|
" <td>9600</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2</th>\n",
|
|||
|
" <td>11250</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>3</th>\n",
|
|||
|
" <td>9550</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>4</th>\n",
|
|||
|
" <td>14260</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>...</th>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1455</th>\n",
|
|||
|
" <td>7917</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1456</th>\n",
|
|||
|
" <td>13175</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1457</th>\n",
|
|||
|
" <td>9042</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1458</th>\n",
|
|||
|
" <td>9717</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1459</th>\n",
|
|||
|
" <td>9937</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"<p>1460 rows × 1 columns</p>\n",
|
|||
|
"</div>\n",
|
|||
|
" <div class=\"colab-df-buttons\">\n",
|
|||
|
"\n",
|
|||
|
" <div class=\"colab-df-container\">\n",
|
|||
|
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-82d1ac63-2545-4535-aa62-9486fd03f7e1')\"\n",
|
|||
|
" title=\"Convert this dataframe to an interactive table.\"\n",
|
|||
|
" style=\"display:none;\">\n",
|
|||
|
"\n",
|
|||
|
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
|||
|
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
|||
|
" </svg>\n",
|
|||
|
" </button>\n",
|
|||
|
"\n",
|
|||
|
" <style>\n",
|
|||
|
" .colab-df-container {\n",
|
|||
|
" display:flex;\n",
|
|||
|
" gap: 12px;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .colab-df-convert {\n",
|
|||
|
" background-color: #E8F0FE;\n",
|
|||
|
" border: none;\n",
|
|||
|
" border-radius: 50%;\n",
|
|||
|
" cursor: pointer;\n",
|
|||
|
" display: none;\n",
|
|||
|
" fill: #1967D2;\n",
|
|||
|
" height: 32px;\n",
|
|||
|
" padding: 0 0 0 0;\n",
|
|||
|
" width: 32px;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .colab-df-convert:hover {\n",
|
|||
|
" background-color: #E2EBFA;\n",
|
|||
|
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
|||
|
" fill: #174EA6;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .colab-df-buttons div {\n",
|
|||
|
" margin-bottom: 4px;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" [theme=dark] .colab-df-convert {\n",
|
|||
|
" background-color: #3B4455;\n",
|
|||
|
" fill: #D2E3FC;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" [theme=dark] .colab-df-convert:hover {\n",
|
|||
|
" background-color: #434B5C;\n",
|
|||
|
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
|||
|
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
|||
|
" fill: #FFFFFF;\n",
|
|||
|
" }\n",
|
|||
|
" </style>\n",
|
|||
|
"\n",
|
|||
|
" <script>\n",
|
|||
|
" const buttonEl =\n",
|
|||
|
" document.querySelector('#df-82d1ac63-2545-4535-aa62-9486fd03f7e1 button.colab-df-convert');\n",
|
|||
|
" buttonEl.style.display =\n",
|
|||
|
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
|||
|
"\n",
|
|||
|
" async function convertToInteractive(key) {\n",
|
|||
|
" const element = document.querySelector('#df-82d1ac63-2545-4535-aa62-9486fd03f7e1');\n",
|
|||
|
" const dataTable =\n",
|
|||
|
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
|||
|
" [key], {});\n",
|
|||
|
" if (!dataTable) return;\n",
|
|||
|
"\n",
|
|||
|
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
|||
|
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
|||
|
" + ' to learn more about interactive tables.';\n",
|
|||
|
" element.innerHTML = '';\n",
|
|||
|
" dataTable['output_type'] = 'display_data';\n",
|
|||
|
" await google.colab.output.renderOutput(dataTable, element);\n",
|
|||
|
" const docLink = document.createElement('div');\n",
|
|||
|
" docLink.innerHTML = docLinkHtml;\n",
|
|||
|
" element.appendChild(docLink);\n",
|
|||
|
" }\n",
|
|||
|
" </script>\n",
|
|||
|
" </div>\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"<div id=\"df-80ed0186-b00b-44aa-9399-e1401cb60ad5\">\n",
|
|||
|
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-80ed0186-b00b-44aa-9399-e1401cb60ad5')\"\n",
|
|||
|
" title=\"Suggest charts\"\n",
|
|||
|
" style=\"display:none;\">\n",
|
|||
|
"\n",
|
|||
|
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
|
|||
|
" width=\"24px\">\n",
|
|||
|
" <g>\n",
|
|||
|
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
|
|||
|
" </g>\n",
|
|||
|
"</svg>\n",
|
|||
|
" </button>\n",
|
|||
|
"\n",
|
|||
|
"<style>\n",
|
|||
|
" .colab-df-quickchart {\n",
|
|||
|
" --bg-color: #E8F0FE;\n",
|
|||
|
" --fill-color: #1967D2;\n",
|
|||
|
" --hover-bg-color: #E2EBFA;\n",
|
|||
|
" --hover-fill-color: #174EA6;\n",
|
|||
|
" --disabled-fill-color: #AAA;\n",
|
|||
|
" --disabled-bg-color: #DDD;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" [theme=dark] .colab-df-quickchart {\n",
|
|||
|
" --bg-color: #3B4455;\n",
|
|||
|
" --fill-color: #D2E3FC;\n",
|
|||
|
" --hover-bg-color: #434B5C;\n",
|
|||
|
" --hover-fill-color: #FFFFFF;\n",
|
|||
|
" --disabled-bg-color: #3B4455;\n",
|
|||
|
" --disabled-fill-color: #666;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .colab-df-quickchart {\n",
|
|||
|
" background-color: var(--bg-color);\n",
|
|||
|
" border: none;\n",
|
|||
|
" border-radius: 50%;\n",
|
|||
|
" cursor: pointer;\n",
|
|||
|
" display: none;\n",
|
|||
|
" fill: var(--fill-color);\n",
|
|||
|
" height: 32px;\n",
|
|||
|
" padding: 0;\n",
|
|||
|
" width: 32px;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .colab-df-quickchart:hover {\n",
|
|||
|
" background-color: var(--hover-bg-color);\n",
|
|||
|
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
|||
|
" fill: var(--button-hover-fill-color);\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .colab-df-quickchart-complete:disabled,\n",
|
|||
|
" .colab-df-quickchart-complete:disabled:hover {\n",
|
|||
|
" background-color: var(--disabled-bg-color);\n",
|
|||
|
" fill: var(--disabled-fill-color);\n",
|
|||
|
" box-shadow: none;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .colab-df-spinner {\n",
|
|||
|
" border: 2px solid var(--fill-color);\n",
|
|||
|
" border-color: transparent;\n",
|
|||
|
" border-bottom-color: var(--fill-color);\n",
|
|||
|
" animation:\n",
|
|||
|
" spin 1s steps(1) infinite;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" @keyframes spin {\n",
|
|||
|
" 0% {\n",
|
|||
|
" border-color: transparent;\n",
|
|||
|
" border-bottom-color: var(--fill-color);\n",
|
|||
|
" border-left-color: var(--fill-color);\n",
|
|||
|
" }\n",
|
|||
|
" 20% {\n",
|
|||
|
" border-color: transparent;\n",
|
|||
|
" border-left-color: var(--fill-color);\n",
|
|||
|
" border-top-color: var(--fill-color);\n",
|
|||
|
" }\n",
|
|||
|
" 30% {\n",
|
|||
|
" border-color: transparent;\n",
|
|||
|
" border-left-color: var(--fill-color);\n",
|
|||
|
" border-top-color: var(--fill-color);\n",
|
|||
|
" border-right-color: var(--fill-color);\n",
|
|||
|
" }\n",
|
|||
|
" 40% {\n",
|
|||
|
" border-color: transparent;\n",
|
|||
|
" border-right-color: var(--fill-color);\n",
|
|||
|
" border-top-color: var(--fill-color);\n",
|
|||
|
" }\n",
|
|||
|
" 60% {\n",
|
|||
|
" border-color: transparent;\n",
|
|||
|
" border-right-color: var(--fill-color);\n",
|
|||
|
" }\n",
|
|||
|
" 80% {\n",
|
|||
|
" border-color: transparent;\n",
|
|||
|
" border-right-color: var(--fill-color);\n",
|
|||
|
" border-bottom-color: var(--fill-color);\n",
|
|||
|
" }\n",
|
|||
|
" 90% {\n",
|
|||
|
" border-color: transparent;\n",
|
|||
|
" border-bottom-color: var(--fill-color);\n",
|
|||
|
" }\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"\n",
|
|||
|
" <script>\n",
|
|||
|
" async function quickchart(key) {\n",
|
|||
|
" const quickchartButtonEl =\n",
|
|||
|
" document.querySelector('#' + key + ' button');\n",
|
|||
|
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
|
|||
|
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
|
|||
|
" try {\n",
|
|||
|
" const charts = await google.colab.kernel.invokeFunction(\n",
|
|||
|
" 'suggestCharts', [key], {});\n",
|
|||
|
" } catch (error) {\n",
|
|||
|
" console.error('Error during call to suggestCharts:', error);\n",
|
|||
|
" }\n",
|
|||
|
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
|
|||
|
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
|
|||
|
" }\n",
|
|||
|
" (() => {\n",
|
|||
|
" let quickchartButtonEl =\n",
|
|||
|
" document.querySelector('#df-80ed0186-b00b-44aa-9399-e1401cb60ad5 button');\n",
|
|||
|
" quickchartButtonEl.style.display =\n",
|
|||
|
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
|||
|
" })();\n",
|
|||
|
" </script>\n",
|
|||
|
"</div>\n",
|
|||
|
"\n",
|
|||
|
" <div id=\"id_bdaa02b2-4993-422b-8713-4dedc6fb07b7\">\n",
|
|||
|
" <style>\n",
|
|||
|
" .colab-df-generate {\n",
|
|||
|
" background-color: #E8F0FE;\n",
|
|||
|
" border: none;\n",
|
|||
|
" border-radius: 50%;\n",
|
|||
|
" cursor: pointer;\n",
|
|||
|
" display: none;\n",
|
|||
|
" fill: #1967D2;\n",
|
|||
|
" height: 32px;\n",
|
|||
|
" padding: 0 0 0 0;\n",
|
|||
|
" width: 32px;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .colab-df-generate:hover {\n",
|
|||
|
" background-color: #E2EBFA;\n",
|
|||
|
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
|||
|
" fill: #174EA6;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" [theme=dark] .colab-df-generate {\n",
|
|||
|
" background-color: #3B4455;\n",
|
|||
|
" fill: #D2E3FC;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" [theme=dark] .colab-df-generate:hover {\n",
|
|||
|
" background-color: #434B5C;\n",
|
|||
|
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
|||
|
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
|||
|
" fill: #FFFFFF;\n",
|
|||
|
" }\n",
|
|||
|
" </style>\n",
|
|||
|
" <button class=\"colab-df-generate\" onclick=\"generateWithVariable('X')\"\n",
|
|||
|
" title=\"Generate code using this dataframe.\"\n",
|
|||
|
" style=\"display:none;\">\n",
|
|||
|
"\n",
|
|||
|
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
|
|||
|
" width=\"24px\">\n",
|
|||
|
" <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n",
|
|||
|
" </svg>\n",
|
|||
|
" </button>\n",
|
|||
|
" <script>\n",
|
|||
|
" (() => {\n",
|
|||
|
" const buttonEl =\n",
|
|||
|
" document.querySelector('#id_bdaa02b2-4993-422b-8713-4dedc6fb07b7 button.colab-df-generate');\n",
|
|||
|
" buttonEl.style.display =\n",
|
|||
|
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
|||
|
"\n",
|
|||
|
" buttonEl.onclick = () => {\n",
|
|||
|
" google.colab.notebook.generateWithVariable('X');\n",
|
|||
|
" }\n",
|
|||
|
" })();\n",
|
|||
|
" </script>\n",
|
|||
|
" </div>\n",
|
|||
|
"\n",
|
|||
|
" </div>\n",
|
|||
|
" </div>\n"
|
|||
|
],
|
|||
|
"application/vnd.google.colaboratory.intrinsic+json": {
|
|||
|
"type": "dataframe",
|
|||
|
"variable_name": "X",
|
|||
|
"summary": "{\n \"name\": \"X\",\n \"rows\": 1460,\n \"fields\": [\n {\n \"column\": \"area\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 9981,\n \"min\": 1300,\n \"max\": 215245,\n \"num_unique_values\": 1073,\n \"samples\": [\n 10186,\n 8163,\n 8854\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
|||
|
}
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"execution_count": 6
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "SqxVaBO0pf1W",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 458
|
|||
|
},
|
|||
|
"outputId": "dfdcb6a7-44fb-4805-bb42-0085a18e0e45"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"Y = dataset.price\n",
|
|||
|
"Y"
|
|||
|
],
|
|||
|
"execution_count": 7,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "execute_result",
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"0 208500\n",
|
|||
|
"1 181500\n",
|
|||
|
"2 223500\n",
|
|||
|
"3 140000\n",
|
|||
|
"4 250000\n",
|
|||
|
" ... \n",
|
|||
|
"1455 175000\n",
|
|||
|
"1456 210000\n",
|
|||
|
"1457 266500\n",
|
|||
|
"1458 142125\n",
|
|||
|
"1459 147500\n",
|
|||
|
"Name: price, Length: 1460, dtype: int64"
|
|||
|
],
|
|||
|
"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>price</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>0</th>\n",
|
|||
|
" <td>208500</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1</th>\n",
|
|||
|
" <td>181500</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2</th>\n",
|
|||
|
" <td>223500</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>3</th>\n",
|
|||
|
" <td>140000</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>4</th>\n",
|
|||
|
" <td>250000</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>...</th>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1455</th>\n",
|
|||
|
" <td>175000</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1456</th>\n",
|
|||
|
" <td>210000</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1457</th>\n",
|
|||
|
" <td>266500</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1458</th>\n",
|
|||
|
" <td>142125</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1459</th>\n",
|
|||
|
" <td>147500</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"<p>1460 rows × 1 columns</p>\n",
|
|||
|
"</div><br><label><b>dtype:</b> int64</label>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"execution_count": 7
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "KsDoGjjbpmjk"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### *Training Dataset using Linear Regression*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "nKmEySI1poV_",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 80
|
|||
|
},
|
|||
|
"outputId": "e8b7d151-62fe-414c-b8c4-381bad76b2a6"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"model = LinearRegression()\n",
|
|||
|
"model.fit(X,Y)"
|
|||
|
],
|
|||
|
"execution_count": 8,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "execute_result",
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"LinearRegression()"
|
|||
|
],
|
|||
|
"text/html": [
|
|||
|
"<style>#sk-container-id-1 {\n",
|
|||
|
" /* Definition of color scheme common for light and dark mode */\n",
|
|||
|
" --sklearn-color-text: #000;\n",
|
|||
|
" --sklearn-color-text-muted: #666;\n",
|
|||
|
" --sklearn-color-line: gray;\n",
|
|||
|
" /* Definition of color scheme for unfitted estimators */\n",
|
|||
|
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
|||
|
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
|||
|
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
|||
|
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
|||
|
" /* Definition of color scheme for fitted estimators */\n",
|
|||
|
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
|||
|
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
|||
|
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
|||
|
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
|||
|
"\n",
|
|||
|
" /* Specific color for light theme */\n",
|
|||
|
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
|||
|
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
|||
|
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
|||
|
" --sklearn-color-icon: #696969;\n",
|
|||
|
"\n",
|
|||
|
" @media (prefers-color-scheme: dark) {\n",
|
|||
|
" /* Redefinition of color scheme for dark theme */\n",
|
|||
|
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
|||
|
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
|||
|
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
|||
|
" --sklearn-color-icon: #878787;\n",
|
|||
|
" }\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 {\n",
|
|||
|
" color: var(--sklearn-color-text);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 pre {\n",
|
|||
|
" padding: 0;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 input.sk-hidden--visually {\n",
|
|||
|
" border: 0;\n",
|
|||
|
" clip: rect(1px 1px 1px 1px);\n",
|
|||
|
" clip: rect(1px, 1px, 1px, 1px);\n",
|
|||
|
" height: 1px;\n",
|
|||
|
" margin: -1px;\n",
|
|||
|
" overflow: hidden;\n",
|
|||
|
" padding: 0;\n",
|
|||
|
" position: absolute;\n",
|
|||
|
" width: 1px;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-dashed-wrapped {\n",
|
|||
|
" border: 1px dashed var(--sklearn-color-line);\n",
|
|||
|
" margin: 0 0.4em 0.5em 0.4em;\n",
|
|||
|
" box-sizing: border-box;\n",
|
|||
|
" padding-bottom: 0.4em;\n",
|
|||
|
" background-color: var(--sklearn-color-background);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-container {\n",
|
|||
|
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
|||
|
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
|||
|
" so we also need the `!important` here to be able to override the\n",
|
|||
|
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
|||
|
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
|||
|
" display: inline-block !important;\n",
|
|||
|
" position: relative;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-text-repr-fallback {\n",
|
|||
|
" display: none;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"div.sk-parallel-item,\n",
|
|||
|
"div.sk-serial,\n",
|
|||
|
"div.sk-item {\n",
|
|||
|
" /* draw centered vertical line to link estimators */\n",
|
|||
|
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
|||
|
" background-size: 2px 100%;\n",
|
|||
|
" background-repeat: no-repeat;\n",
|
|||
|
" background-position: center center;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Parallel-specific style estimator block */\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-parallel-item::after {\n",
|
|||
|
" content: \"\";\n",
|
|||
|
" width: 100%;\n",
|
|||
|
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
|||
|
" flex-grow: 1;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-parallel {\n",
|
|||
|
" display: flex;\n",
|
|||
|
" align-items: stretch;\n",
|
|||
|
" justify-content: center;\n",
|
|||
|
" background-color: var(--sklearn-color-background);\n",
|
|||
|
" position: relative;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-parallel-item {\n",
|
|||
|
" display: flex;\n",
|
|||
|
" flex-direction: column;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-parallel-item:first-child::after {\n",
|
|||
|
" align-self: flex-end;\n",
|
|||
|
" width: 50%;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-parallel-item:last-child::after {\n",
|
|||
|
" align-self: flex-start;\n",
|
|||
|
" width: 50%;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-parallel-item:only-child::after {\n",
|
|||
|
" width: 0;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Serial-specific style estimator block */\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-serial {\n",
|
|||
|
" display: flex;\n",
|
|||
|
" flex-direction: column;\n",
|
|||
|
" align-items: center;\n",
|
|||
|
" background-color: var(--sklearn-color-background);\n",
|
|||
|
" padding-right: 1em;\n",
|
|||
|
" padding-left: 1em;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
|||
|
"clickable and can be expanded/collapsed.\n",
|
|||
|
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
|||
|
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
|||
|
"*/\n",
|
|||
|
"\n",
|
|||
|
"/* Pipeline and ColumnTransformer style (default) */\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-toggleable {\n",
|
|||
|
" /* Default theme specific background. It is overwritten whether we have a\n",
|
|||
|
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
|||
|
" background-color: var(--sklearn-color-background);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Toggleable label */\n",
|
|||
|
"#sk-container-id-1 label.sk-toggleable__label {\n",
|
|||
|
" cursor: pointer;\n",
|
|||
|
" display: flex;\n",
|
|||
|
" width: 100%;\n",
|
|||
|
" margin-bottom: 0;\n",
|
|||
|
" padding: 0.5em;\n",
|
|||
|
" box-sizing: border-box;\n",
|
|||
|
" text-align: center;\n",
|
|||
|
" align-items: start;\n",
|
|||
|
" justify-content: space-between;\n",
|
|||
|
" gap: 0.5em;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 label.sk-toggleable__label .caption {\n",
|
|||
|
" font-size: 0.6rem;\n",
|
|||
|
" font-weight: lighter;\n",
|
|||
|
" color: var(--sklearn-color-text-muted);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n",
|
|||
|
" /* Arrow on the left of the label */\n",
|
|||
|
" content: \"▸\";\n",
|
|||
|
" float: left;\n",
|
|||
|
" margin-right: 0.25em;\n",
|
|||
|
" color: var(--sklearn-color-icon);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n",
|
|||
|
" color: var(--sklearn-color-text);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Toggleable content - dropdown */\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-toggleable__content {\n",
|
|||
|
" max-height: 0;\n",
|
|||
|
" max-width: 0;\n",
|
|||
|
" overflow: hidden;\n",
|
|||
|
" text-align: left;\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-toggleable__content.fitted {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-toggleable__content pre {\n",
|
|||
|
" margin: 0.2em;\n",
|
|||
|
" border-radius: 0.25em;\n",
|
|||
|
" color: var(--sklearn-color-text);\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
|||
|
" /* Expand drop-down */\n",
|
|||
|
" max-height: 200px;\n",
|
|||
|
" max-width: 100%;\n",
|
|||
|
" overflow: auto;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
|||
|
" content: \"▾\";\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Pipeline/ColumnTransformer-specific style */\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
|||
|
" color: var(--sklearn-color-text);\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Estimator-specific style */\n",
|
|||
|
"\n",
|
|||
|
"/* Colorize estimator box */\n",
|
|||
|
"#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n",
|
|||
|
"#sk-container-id-1 div.sk-label label {\n",
|
|||
|
" /* The background is the default theme color */\n",
|
|||
|
" color: var(--sklearn-color-text-on-default-background);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* On hover, darken the color of the background */\n",
|
|||
|
"#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n",
|
|||
|
" color: var(--sklearn-color-text);\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Label box, darken color on hover, fitted */\n",
|
|||
|
"#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
|||
|
" color: var(--sklearn-color-text);\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Estimator label */\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-label label {\n",
|
|||
|
" font-family: monospace;\n",
|
|||
|
" font-weight: bold;\n",
|
|||
|
" display: inline-block;\n",
|
|||
|
" line-height: 1.2em;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-label-container {\n",
|
|||
|
" text-align: center;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Estimator-specific */\n",
|
|||
|
"#sk-container-id-1 div.sk-estimator {\n",
|
|||
|
" font-family: monospace;\n",
|
|||
|
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
|||
|
" border-radius: 0.25em;\n",
|
|||
|
" box-sizing: border-box;\n",
|
|||
|
" margin-bottom: 0.5em;\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-estimator.fitted {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* on hover */\n",
|
|||
|
"#sk-container-id-1 div.sk-estimator:hover {\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 div.sk-estimator.fitted:hover {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
|||
|
"\n",
|
|||
|
"/* Common style for \"i\" and \"?\" */\n",
|
|||
|
"\n",
|
|||
|
".sk-estimator-doc-link,\n",
|
|||
|
"a:link.sk-estimator-doc-link,\n",
|
|||
|
"a:visited.sk-estimator-doc-link {\n",
|
|||
|
" float: right;\n",
|
|||
|
" font-size: smaller;\n",
|
|||
|
" line-height: 1em;\n",
|
|||
|
" font-family: monospace;\n",
|
|||
|
" background-color: var(--sklearn-color-background);\n",
|
|||
|
" border-radius: 1em;\n",
|
|||
|
" height: 1em;\n",
|
|||
|
" width: 1em;\n",
|
|||
|
" text-decoration: none !important;\n",
|
|||
|
" margin-left: 0.5em;\n",
|
|||
|
" text-align: center;\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
|||
|
" color: var(--sklearn-color-unfitted-level-1);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
".sk-estimator-doc-link.fitted,\n",
|
|||
|
"a:link.sk-estimator-doc-link.fitted,\n",
|
|||
|
"a:visited.sk-estimator-doc-link.fitted {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
|||
|
" color: var(--sklearn-color-fitted-level-1);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* On hover */\n",
|
|||
|
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
|||
|
".sk-estimator-doc-link:hover,\n",
|
|||
|
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
|||
|
".sk-estimator-doc-link:hover {\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
|||
|
" color: var(--sklearn-color-background);\n",
|
|||
|
" text-decoration: none;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
|||
|
".sk-estimator-doc-link.fitted:hover,\n",
|
|||
|
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
|||
|
".sk-estimator-doc-link.fitted:hover {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
|||
|
" color: var(--sklearn-color-background);\n",
|
|||
|
" text-decoration: none;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* Span, style for the box shown on hovering the info icon */\n",
|
|||
|
".sk-estimator-doc-link span {\n",
|
|||
|
" display: none;\n",
|
|||
|
" z-index: 9999;\n",
|
|||
|
" position: relative;\n",
|
|||
|
" font-weight: normal;\n",
|
|||
|
" right: .2ex;\n",
|
|||
|
" padding: .5ex;\n",
|
|||
|
" margin: .5ex;\n",
|
|||
|
" width: min-content;\n",
|
|||
|
" min-width: 20ex;\n",
|
|||
|
" max-width: 50ex;\n",
|
|||
|
" color: var(--sklearn-color-text);\n",
|
|||
|
" box-shadow: 2pt 2pt 4pt #999;\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background: var(--sklearn-color-unfitted-level-0);\n",
|
|||
|
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
".sk-estimator-doc-link.fitted span {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" background: var(--sklearn-color-fitted-level-0);\n",
|
|||
|
" border: var(--sklearn-color-fitted-level-3);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
".sk-estimator-doc-link:hover span {\n",
|
|||
|
" display: block;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 a.estimator_doc_link {\n",
|
|||
|
" float: right;\n",
|
|||
|
" font-size: 1rem;\n",
|
|||
|
" line-height: 1em;\n",
|
|||
|
" font-family: monospace;\n",
|
|||
|
" background-color: var(--sklearn-color-background);\n",
|
|||
|
" border-radius: 1rem;\n",
|
|||
|
" height: 1rem;\n",
|
|||
|
" width: 1rem;\n",
|
|||
|
" text-decoration: none;\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" color: var(--sklearn-color-unfitted-level-1);\n",
|
|||
|
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 a.estimator_doc_link.fitted {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
|||
|
" color: var(--sklearn-color-fitted-level-1);\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"/* On hover */\n",
|
|||
|
"#sk-container-id-1 a.estimator_doc_link:hover {\n",
|
|||
|
" /* unfitted */\n",
|
|||
|
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
|||
|
" color: var(--sklearn-color-background);\n",
|
|||
|
" text-decoration: none;\n",
|
|||
|
"}\n",
|
|||
|
"\n",
|
|||
|
"#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n",
|
|||
|
" /* fitted */\n",
|
|||
|
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
|||
|
"}\n",
|
|||
|
"</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LinearRegression()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow\"><div><div>LinearRegression</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.6/modules/generated/sklearn.linear_model.LinearRegression.html\">?<span>Documentation for LinearRegression</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\"><pre>LinearRegression()</pre></div> </div></div></div></div>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"execution_count": 8
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "n-UeFqpGpw9p"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### *Predicted Price for Land sq.Feet of custom values*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "Ollo3wTcpyKQ",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/"
|
|||
|
},
|
|||
|
"outputId": "365ec852-2686-4b53-85ec-56783730f77f"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"x=2400\n",
|
|||
|
"LandAreainSqFt=[[x]]\n",
|
|||
|
"PredictedmodelResult = model.predict(LandAreainSqFt)\n",
|
|||
|
"print(PredictedmodelResult)"
|
|||
|
],
|
|||
|
"execution_count": 13,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"name": "stdout",
|
|||
|
"text": [
|
|||
|
"[163876.08458098]\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"name": "stderr",
|
|||
|
"text": [
|
|||
|
"/usr/local/lib/python3.11/dist-packages/sklearn/utils/validation.py:2739: UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names\n",
|
|||
|
" warnings.warn(\n"
|
|||
|
]
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "1PbTSCtSp3lC"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### Let's check is our model is Right ?\n",
|
|||
|
"### Theory Calculation\n",
|
|||
|
"### Y = m * X + b (m is coefficient and b is intercept)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "T5eVVDPvp8Hc"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"*Coefficient - m*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "1SvYtiI2p4ZB",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/"
|
|||
|
},
|
|||
|
"outputId": "d9726623-f842-4474-e680-d61ca7cefa09"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"m=model.coef_\n",
|
|||
|
"print(m)"
|
|||
|
],
|
|||
|
"execution_count": 14,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"name": "stdout",
|
|||
|
"text": [
|
|||
|
"[2.09997195]\n"
|
|||
|
]
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "nSXLgArvqBu2"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"*Intercept - b*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "mxyroJ6uqCet",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/"
|
|||
|
},
|
|||
|
"outputId": "f8bfef10-61d7-456b-e860-0eb4bf5a047a"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"b=model.intercept_\n",
|
|||
|
"print(b)"
|
|||
|
],
|
|||
|
"execution_count": 15,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"name": "stdout",
|
|||
|
"text": [
|
|||
|
"158836.1518968766\n"
|
|||
|
]
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "VCLG6YIOqEaX"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"### Y=mx+b\n",
|
|||
|
"*x is Independant variable - Input - area*"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "kRHG8tUFqO1i",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/"
|
|||
|
},
|
|||
|
"outputId": "83287893-80dc-4c5c-d20b-595ac364519b"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"y = m*x + b\n",
|
|||
|
"print(\"The Price of {0} Square feet Land is: {1}\".format(x,y[0]))"
|
|||
|
],
|
|||
|
"execution_count": 16,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"name": "stdout",
|
|||
|
"text": [
|
|||
|
"The Price of 2400 Square feet Land is: 163876.08458097503\n"
|
|||
|
]
|
|||
|
}
|
|||
|
]
|
|||
|
}
|
|||
|
]
|
|||
|
}
|