This project implements a house price prediction system using Linear Regression. It is built as an end-to-end machine-learning project using Flask.
The goal of this project is to predict the price of houses based on various features such as location, total square feet area, number of bathrooms, and number of bedrooms.
- Predicts house prices based on user input.
- Web-based interface for easy interaction.
- Multiple ML models tested to select the best one.
- Uses Ridge Regression as the final model after evaluation.
- End-to-end ML project integrated with Flask.
The project is structured as follows:
app.py
: Flask web application for serving predictions.model/
: Directory containing trained model and preprocessing objects.dataset/
: Directory containing the dataset used for training.templates/
: HTML templates for the web interface.
Several machine learning models were trained and evaluated using 5-Fold Cross-Validation. The Ridge Regression model achieved the best performance.
Model | Mean Cross-Validation R² Score |
---|---|
Linear Regression | 0.8035 |
Lasso Regression | 0.7924 |
Ridge Regression | 0.8035 |
Decision Tree Regressor | 0.6526 |
Random Forest Regressor | 0.7607 |
XGBoost Regressor | 0.7144 |
SVR (Support Vector Regressor) | 0.1645 |
✅ Best Model Before Tuning: Ridge Regression
✅ Final Selected Model: Ridge Regression
✅ Final Test R² Score: 0.8177
📌 Why Ridge Regression?
- Performs better than tree-based models for this dataset.
- Prevents overfitting by applying regularization.
- Achieved the highest cross-validation score.
-
Clone the repository:
git clone https://github.com/kindo-tk/house_price_prediction.git
-
Navigate to the project directory:
cd .\house_price_prediction\
-
Create a virtual environment:
python -m venv .venv
-
Activate the virtual environment:
.venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
-
Run the Flask application:
python app.py
- Access the web application by navigating to http://localhost:5000 in your web browser.
- Enter the required details such as location, total square feet area, number of bathrooms, and number of bedrooms.
- Click on the "Predict Price" button to get the predicted house price.
- Python
- Flask
- HTML/CSS
- Bootstrap
- scikit-learn
This project is licensed under the MIT License - see the LICENSE file for details.
For any inquiries or feedback, please contact: