Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 234 additions & 0 deletions ML_model_.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "ML model .ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"metadata": {
"id": "px3FIaPsIBbE"
},
"source": [
"import pandas as pd\n"
],
"execution_count": 1,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "28M0pnrcINm0",
"outputId": "67793889-7b09-404f-aaaf-c0571c169bfb"
},
"source": [
"regressor = pd.read_pickle('HousePricePredictor')\n",
"regressor"
],
"execution_count": 2,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None, normalize=False)"
]
},
"metadata": {
"tags": []
},
"execution_count": 2
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "LMz9flPPKGjl"
},
"source": [
"cols=['Avg. Area Income', 'Avg. Area House Age', 'Avg. Area Number of Rooms', 'Area Population']"
],
"execution_count": 3,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "icQkIPd0Kfsx"
},
"source": [
"ASK USER INCOME"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Ua51aC9KKa8T",
"outputId": "b113bb6b-8bdd-46ed-f718-e55a026d0b01"
},
"source": [
"income= eval(input('enter the income:'))\n",
"house_age = eval(input('enter the house age:'))\n",
"rooms= eval(input('enter the number of rooms:'))\n",
"population =eval(input('enter the population'))\n",
"query=pd.DataFrame({'Avg.Area Income':[income],\n",
" 'Avg.Area House Age':[house_age],\n",
" 'Avg. Area Number of Rooms':[rooms],\n",
" 'Avg Population':[population]\n",
" })\n"
],
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"text": [
"enter the income:100000\n",
"enter the house age:2\n",
"enter the number of rooms:6\n",
"enter the population10000\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 97
},
"id": "T3_w-5qnNkfS",
"outputId": "694b950b-9480-4847-b6bc-b9861cfe5ede"
},
"source": [
"query"
],
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"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>Avg.Area Income</th>\n",
" <th>Avg.Area House Age</th>\n",
" <th>Avg. Area Number of Rooms</th>\n",
" <th>Avg Population</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>100000</td>\n",
" <td>2</td>\n",
" <td>6</td>\n",
" <td>10000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Avg.Area Income ... Avg Population\n",
"0 100000 ... 10000\n",
"\n",
"[1 rows x 4 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "FkA9N5F9Mskc",
"outputId": "0c3b534d-7868-46d2-baea-89936611c463"
},
"source": [
"regressor.predict(query)[0]"
],
"execution_count": 8,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"733683.1258376497"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "T47rbR7UM0cz",
"outputId": "7d8c4232-6189-49ff-cc65-3ae39babaaaf"
},
"source": [
"print('price for the house can be:%.1f$'%(regressor.predict(query)[0]))"
],
"execution_count": 9,
"outputs": [
{
"output_type": "stream",
"text": [
"price for the house can be:733683.1$\n"
],
"name": "stdout"
}
]
}
]
}
Loading