Data Science Project: USA_Home_Price_Prediction
Explanation
Banglore-House-Price-Prediction
Banglore House Price Prediction - Machine Learning ProjectI Explain the whole process in the next video:Table of Contents
Introduction Dataset Data Preprocessing Feature Engineering Models Used Evaluation Metrics Results Conclusion Future Work References 1. Introduction
The Bangalore House Price Prediction project aims to predict the prices of houses in Bangalore using various regression models. This project involves data preprocessing, feature engineering, model training, evaluation, and comparison to identify the most effective model for predicting house prices.2. Dataset
The dataset used in this project is sourced from Kaggle: Bengaluru House Price Data. It contains various features such as area type, location, size, total square feet, number of bathrooms and the price of the house.3. Data Cleaning
Data preprocessing steps include:
Handling missing values by dropping columns with a high percentage of missing data. Converting categorical features to numeric using techniques such as one-hot encoding. 4. Feature Engineering
Feature engineering involves:
reducing the unique values at the categorical columns "locations" to avoid dimentionality curse all of the categories with less than 10 entries with shares the same categorical name = "others" 5 Outlier Removal
finding spacial case of ratio bedroom-bathroom and remove then from data set leaning up the dataframe by removing properties that have significantly lower prices per square foot compared to properties with one less bedroom resulting plost will help visualize whether 2 BHK apartments are cheaper or more expensive compared to 3 BHK apartments in Hebbal, repeting this process many times to check and identify outliers 6. Models Used
next algorithm and paramenter were testedalgos = {
'linear_regression': {'model': LinearRegression(),'params': {'fit_intercept': [True, False]}},'lasso': {'model': Lasso(),'params': {'alpha': [1, 2],'selection': ['random', 'cyclic']}},'decision_tree': {'model': DecisionTreeRegressor(),'params': {'criterion': ['mse', 'friedman_mse'],'splitter': ['best', 'random']}}}7. Evaluation Metrics
| model | best_score | best_params | | --- | --- | --- | --- | | 0 | linear_regression | 0.819001 | {'fit_intercept': False} | | 1 | lasso | 0.687476 | {'alpha': 2, 'selection': 'random'} | | 2 | decision_tree | 0.712039 | {'criterion': 'friedman_mse', 'splitter': 'best'} |8. Conclusion
In conclusion, the linear Regression model provided the best performance with the accuracy score of 0.845227769787429 , making it the most suitable model for predicting house prices in Bangalore.9. References
Kaggle Dataset: Bengaluru House Price Data Scikit-learn documentation: Scikit-learn XGBoost documentation: XGBoost This README provides an overview of the Bangalore House Price Prediction project, detailing the steps taken, models used, and their performance, along with insights and future directions ---------------------------------------------------------------
Home Price Prediction Flask App
This repository contains a Flask web application that predicts home prices based on several features such as the number of bedrooms, bathrooms, lot size, state, and house size. The app uses a pre-trained linear regression model to make predictions.Table of Contents
Installation Usage API Endpoints File Descriptions UI Components Contributing License Installation
Clone the repository:bash git clone https://github.com/yourusername/home-price-prediction.git
cd home-price-predictionCreate a virtual environment:bash python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Set up artifacts:
Ensure the pre-trained model (Indian_home_price_lr_model
) and columns.json
are placed in the ./artifacts
directory. Usage
Start the Flask server:bash python server.py
Access the API endpoints:
Open your browser and navigate to http://127.0.0.1:5000/get_location_names
to get the list of location names. Use a tool like Postman to test the /predict_home_price
endpoint with a POST request. API Endpoints
GET /get_location_names
Description: Returns a list of location names. Response:json {
"locations": ["state1", "state2", "state3", ...]}POST /predict_home_price
Description: Predicts the home price based on the provided features. Request:
bed
: Number of bedrooms (float)bath
: Number of bathrooms (float)location
: city name (string)house_size
: Size of the house in square feet (float)Response:json {
"estimated_price": 123456.78}File Descriptions
server.py
The main Flask application file that defines the API endpoints. Loads the saved artifacts (model and column names) from disk. Handles incoming requests and uses the utility functions to get predictions. util.py
Contains utility functions for loading saved artifacts, predicting home prices, and retrieving location names. Defines functions to deserialize the model and columns data. Provides helper functions for making predictions using the loaded model. columns.json
A JSON file containing the column names of the dataset used for training the model. USA_Real_state_lr_model_pickle
A pickle file containing the serialized pre-trained linear regression model. app.css
Contains the CSS styles for the web interface, including general styles and form styling. app.html
The HTML file defining the structure and layout of the web interface, including the form for user inputs. app.js
Contains the JavaScript code to handle form submissions, interact with the Flask API, and update the UI dynamically. UI Components
CSS (app.css
)
General Styles: Defines styles for the body, headings, and form elements. Form Styling: Styles the form for user inputs, including text fields, radio buttons, and the submit button. HTML (app.html
)
Structure: Defines the structure of the web page, including headings, input fields, and the form. Form Elements: Contains input fields for house size, lot size, number of rooms, number of bathrooms, and state selection. JavaScript (app.js
)
Form Handling: Contains functions to get values from the form, send requests to the Flask API, and display the estimated price. Page Load: Loads location names from the API when the page is loaded.
algos = {
git clone https://github.com/yourusername/home-price-prediction.git
python -m venv venv
Indian_home_price_lr_model
) and columns.json
are placed in the ./artifacts
directory.python server.py
http://127.0.0.1:5000/get_location_names
to get the list of location names./predict_home_price
endpoint with a POST request./get_location_names
{
/predict_home_price
bed
: Number of bedrooms (float)bath
: Number of bathrooms (float)location
: city name (string)house_size
: Size of the house in square feet (float){
server.py
util.py
columns.json
USA_Real_state_lr_model_pickle
app.css
app.html
app.js
app.css
)app.html
)app.js
)