Coconote
AI notes
AI voice & video notes
Try for free
🏡
Bangalore House Price Prediction Project
Oct 27, 2024
House Price Prediction in Bangalore
Overview
Goal: Predict price of a new house in Bangalore.
Example:
Location: 6th Phase JP Nagar
Configuration: 4 BHK, 3 bathrooms, 2000 sqft
Predicted Price: 1 crore 43 lakhs INR
Tools and Technologies Used
Flask
: For building the web application
Bootstrap
: For designing the frontend
JavaScript
: To display predictions on the same page without redirecting
Dataset
Source: Kaggle (Bengaluru house price data)
File:
bangalorehouse_data.csv
Structure:
Columns
:
Area Type
Availability
Location
Size (BHK)
Total Square Feet
Bathrooms
Balconies
Price (in lakhs)
Data Exploration
Shape: 13,300 rows, 9 columns
Data Types:
Area Type: categorical
Availability: categorical
Location: categorical
Size: categorical
Bathrooms: numerical
Price: numerical
Data Cleaning
Handling Missing Values
:
Dropped columns: Area Type, Availability, Society, and Balcony due to high missing values.
Filled missing location values with 'Sarjapur'.
Filled missing size values with '2 BHK'.
Replaced bathroom nulls with median bathroom value.
Outlier Detection
:
Cleaned total square feet values to fix ranges.
Dropped outliers based on price per square feet and BHK stats.
Feature Engineering
:
Created
price per square feet
column.
Stripped leading/trailing whitespace from location strings and categorized locations with low counts as 'Other'.
Model Building
Models Used:
Linear Regression
Lasso Regression
Ridge Regression
Steps:
Imported necessary libraries
Trained models using cleaned dataset
Used pipelines for preprocessing and model fitting
Flask Application
Setup
:
Created a basic Flask skeleton.
Implemented HTML template with Bootstrap for styling.
Form included fields for location, BHK, bathrooms, and total square feet.
JavaScript Integration
:
Managed form submission without page reload using XMLHttpRequest.
Displayed prediction results dynamically.
Prediction Logic
:
Loaded the trained model using Pickle.
Form input data was transformed into a DataFrame for predictions.
Displayed the prediction in lakhs, converted to rupees for final output.
Deployment
Suggested using Flask-Cors for handling API requests in production (e.g., Heroku).
Conclusion
Successfully built a web application to predict house prices in Bangalore based on user inputs.
Achieved a good R2 score with the model, indicating predictive accuracy.
📄
Full transcript