diff --git a/models/Check_Models.ipynb b/models/Check_Models.ipynb new file mode 100644 index 0000000..3cff599 --- /dev/null +++ b/models/Check_Models.ipynb @@ -0,0 +1,292 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "4d1c650b-01a0-4414-99ee-64f80bb561f1", + "metadata": {}, + "outputs": [], + "source": [ + "import pickle\n", + "import numpy as np\n", + "import pandas as pd\n", + "pd.set_option('display.max_rows', None)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "3c54e2be-71ea-4ace-b598-fa5bc2393f43", + "metadata": {}, + "outputs": [], + "source": [ + "# Load the pickled XGBoost model MUMBAI\n", + "with open('best_xgb_mumbai.pkl', 'rb') as f:\n", + " model = pickle.load(f)\n", + "\n", + "# Define the feature columns and their values\n", + "feature_columns = ['DiningTable', 'Refrigerator', 'JoggingTrack', 'BED', 'Area', 'AC',\n", + " 'RainWaterHarvesting', 'No. of Bedrooms', 'Location_encoded',\n", + " 'WashingMachine', 'Microwave', 'Intercom', 'Gymnasium', 'TV',\n", + " 'StaffQuarter', 'MultipurposeRoom', '24X7Security', 'IndoorGames',\n", + " 'Cafeteria', 'Gasconnection']\n", + "feature_values = [0, 0, 0, 0, 720, 0, 0, 1, 325, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "665e2222-c960-49b0-8f3d-5a8f5e560595", + "metadata": {}, + "outputs": [], + "source": [ + "# Convert feature_values to numpy array\n", + "X = np.array(feature_values).reshape(1, -1)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "1fe18a9f-b5c4-4800-b322-9ce3fab4a50c", + "metadata": {}, + "outputs": [], + "source": [ + "# Make prediction\n", + "predicted_price = model.predict(X)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "6f7911ae-f634-4837-bca5-10b730835eb2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([4846619.5], dtype=float32)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "predicted_price\n", + "# ACTUAL PRICE WAS 4850000 SO THIS MODEL PREDICTS PROPERTY PRICES VERY WELL for a train observation" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "033d09f7-bbbe-4756-99ef-c87508a6a735", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Predicted Price for Bangalore: 4579130.0\n" + ] + } + ], + "source": [ + "# Load the pickled XGBoost model for Bangalore\n", + "with open('best_xgb_bangalore.pkl', 'rb') as f:\n", + " model_bangalore = pickle.load(f)\n", + "\n", + "# Define the feature columns and their values for Bangalore\n", + "feature_columns_bangalore = ['Area', 'MaintenanceStaff', 'Intercom', 'IndoorGames', 'School',\n", + " 'StaffQuarter', 'LiftAvailable', 'Gasconnection', 'LandscapedGardens',\n", + " 'VaastuCompliant', 'Hospital', 'ATM', 'ShoppingMall', 'GolfCourse',\n", + " 'Location_encoded', '24X7Security', 'CarParking', 'Cafeteria',\n", + " 'WashingMachine', 'RainWaterHarvesting']\n", + "feature_values_bangalore = [1304, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 561, 1, 1, 0, 0, 1]\n", + "\n", + "# Convert feature_values to numpy array\n", + "X_bangalore = np.array(feature_values_bangalore).reshape(1, -1)\n", + "\n", + "# Make prediction for Bangalore\n", + "predicted_price_bangalore = model_bangalore.predict(X_bangalore)\n", + "\n", + "print(\"Predicted Price for Bangalore:\", predicted_price_bangalore[0])\n", + "# Actual price was 4433000 SO THIS MODEL PREDICTS PROPERTY PRICES VERY WELL" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "8e20b150-29f3-4765-b62b-b33f331d36dc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Predicted Price for Chennai: 2740017.0\n" + ] + } + ], + "source": [ + "# Load the pickled XGBoost model for Chennai\n", + "with open('best_xgb_chennai.pkl', 'rb') as f:\n", + " model_chennai = pickle.load(f)\n", + "\n", + "# Define the feature columns and their values for Chennai\n", + "feature_columns_chennai = ['Area', 'JoggingTrack', 'Cafeteria', 'RainWaterHarvesting', 'No. of Bedrooms',\n", + " 'MultipurposeRoom', 'Refrigerator', 'ShoppingMall', 'VaastuCompliant',\n", + " 'Location_encoded', 'Sofa', 'SwimmingPool', 'IndoorGames', 'LandscapedGardens',\n", + " 'BED', 'ClubHouse', 'SportsFacility', 'Resale', 'WashingMachine', 'AC']\n", + "feature_values_chennai = [563, 0, 0, 1, 1, 0, 0, 0, 0, 753, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0]\n", + "\n", + "# Convert feature_values to numpy array\n", + "X_chennai = np.array(feature_values_chennai).reshape(1, -1)\n", + "\n", + "# Make prediction for Chennai\n", + "predicted_price_chennai = model_chennai.predict(X_chennai)\n", + "\n", + "print(\"Predicted Price for Chennai:\", predicted_price_chennai[0])\n", + "# Actual Price is 2740000" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "f732f3a9-0edc-43c6-b08e-8c79d25866a6", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Predicted Price for Hyderabad: 8393575.0\n" + ] + } + ], + "source": [ + "# Load the pickled XGBoost model for Hyderabad\n", + "with open('best_xgb_hyderabad.pkl', 'rb') as f:\n", + " model_hyderabad = pickle.load(f)\n", + "\n", + "# Define the feature columns and their values for Hyderabad\n", + "feature_columns_hyderabad = ['Area', 'Resale', 'BED', 'SwimmingPool', 'ClubHouse', 'Gymnasium',\n", + " 'CarParking', 'LiftAvailable', 'LandscapedGardens', 'IndoorGames',\n", + " 'MultipurposeRoom', 'ATM', 'Location_encoded', 'MaintenanceStaff',\n", + " 'School', 'Cafeteria', 'No. of Bedrooms', 'Gasconnection', 'AC', 'Intercom']\n", + "feature_values_hyderabad = [1951, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 47, 0, 0, 0, 3, 0, 0, 1]\n", + "\n", + "# Convert feature_values to numpy array\n", + "X_hyderabad = np.array(feature_values_hyderabad).reshape(1, -1)\n", + "\n", + "# Make prediction for Hyderabad\n", + "predicted_price_hyderabad = model_hyderabad.predict(X_hyderabad)\n", + "\n", + "print(\"Predicted Price for Hyderabad:\", predicted_price_hyderabad[0])\n", + "# Actual value was 8387000. " + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "6feaa1b5-8978-4859-b4ee-10eacd6c26a4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Predicted Price for Delhi: 4365190.0\n" + ] + } + ], + "source": [ + "# Load the pickled XGBoost model for Delhi\n", + "with open('best_xgb_delhi.pkl', 'rb') as f:\n", + " model_delhi = pickle.load(f)\n", + "\n", + "# Define the feature columns and their values for Delhi\n", + "feature_columns_delhi = ['Area', 'Resale', 'Location_encoded', 'IndoorGames', 'AC', 'DiningTable',\n", + " 'Intercom', 'BED', 'No. of Bedrooms', \"Children'splayarea\", 'Microwave',\n", + " 'CarParking', 'RainWaterHarvesting', 'LiftAvailable', 'Gasconnection',\n", + " 'PowerBackup', 'Refrigerator', 'MaintenanceStaff', 'SwimmingPool', 'SportsFacility']\n", + "feature_values_delhi = [800, 1, 836, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]\n", + "\n", + "# Convert feature_values to numpy array\n", + "X_delhi = np.array(feature_values_delhi).reshape(1, -1)\n", + "\n", + "# Make prediction for Delhi\n", + "predicted_price_delhi = model_delhi.predict(X_delhi)\n", + "\n", + "print(\"Predicted Price for Delhi:\", predicted_price_delhi[0])\n", + "# Actual Price is 4200000" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "0e535a06-5019-40e7-ad5a-7d7a6f0c1839", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Predicted Price for Kolkata: 7936000.5\n" + ] + } + ], + "source": [ + "# Load the pickled XGBoost model for Kolkata\n", + "with open('best_xgb_kolkata.pkl', 'rb') as f:\n", + " model_kolkata = pickle.load(f)\n", + "\n", + "# Define the feature columns and their values for Kolkata\n", + "feature_columns_kolkata = ['Area', 'SwimmingPool', 'Resale', 'ClubHouse', 'RainWaterHarvesting',\n", + " 'Cafeteria', 'LiftAvailable', 'MaintenanceStaff', 'Location_encoded',\n", + " 'JoggingTrack', 'LandscapedGardens', 'No. of Bedrooms', 'VaastuCompliant',\n", + " 'MultipurposeRoom', 'PowerBackup', 'IndoorGames', 'WashingMachine',\n", + " 'CarParking', 'SportsFacility', 'Gymnasium']\n", + "feature_values_kolkata = [1310, 1, 0, 1, 1, 1, 1, 0, 174, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 1]\n", + "\n", + "# Convert feature_values to numpy array\n", + "X_kolkata = np.array(feature_values_kolkata).reshape(1, -1)\n", + "\n", + "# Make prediction for Kolkata\n", + "predicted_price_kolkata = model_kolkata.predict(X_kolkata)\n", + "\n", + "print(\"Predicted Price for Kolkata:\", predicted_price_kolkata[0])\n", + "# Actual price is 7936000. So predicted price is very close" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "687d07e4-b3c1-405d-a7e2-dddb0dd6fd6a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "metro_housing", + "language": "python", + "name": "metro_housing" + }, + "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.9.18" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/models/best_xgb_bangalore.pkl b/models/best_xgb_bangalore.pkl new file mode 100644 index 0000000..62416e0 Binary files /dev/null and b/models/best_xgb_bangalore.pkl differ diff --git a/models/best_xgb_chennai.pkl b/models/best_xgb_chennai.pkl new file mode 100644 index 0000000..7749720 Binary files /dev/null and b/models/best_xgb_chennai.pkl differ diff --git a/models/best_xgb_delhi.pkl b/models/best_xgb_delhi.pkl new file mode 100644 index 0000000..4de9f87 Binary files /dev/null and b/models/best_xgb_delhi.pkl differ diff --git a/models/best_xgb_hyderabad.pkl b/models/best_xgb_hyderabad.pkl new file mode 100644 index 0000000..9e6fe6e Binary files /dev/null and b/models/best_xgb_hyderabad.pkl differ diff --git a/models/best_xgb_mumbai.pkl b/models/best_xgb_mumbai.pkl new file mode 100644 index 0000000..f53e67c Binary files /dev/null and b/models/best_xgb_mumbai.pkl differ diff --git a/models/encoded location wise city (1).pdf b/models/encoded location wise city (1).pdf new file mode 100644 index 0000000..94dc351 Binary files /dev/null and b/models/encoded location wise city (1).pdf differ