This project is a web application for predicting house prices in California using machine learning (I use a sklearn dataset fetch_california_housing). Users can input various characteristics of a house, and based on this data, the model predicts the price of the house.
house_price_predictor/
│
├── app/
│ ├── init.py
│ ├── routes.py
│ ├── forms.py
│ └── templates/
│ ├── base.html
│ ├── index.html
├── models/
│ ├── train_model.py
│ └── model.pkl
├── run.py
└── requirements.txt
app/
: Directory containing the code for the web application.routes.py
: Application routes.forms.py
: Form definition for data input.templates/
: HTML templates for displaying the user interface.
models/
: Directory containing files for model training and the saved trained model.model.pkl
: Trained modeltrain_model.py
: Model training file
run.py
: File to run the web application.requirements.txt
: Project dependencies file.
Users can input the following house characteristics for price prediction:
- Median Income (Median Income): Median household income in the area (in tens of thousands of dollars).
- House Age (House Age): Average house age in the area (in years).
- Average Number of Rooms (Average Rooms): Average number of rooms in the house.
- Average Number of Bedrooms (Average Bedrooms): Average number of bedrooms in the house.
- Population (Population): Population of the area.
- Average Occupancy (Average Occupancy): Average house occupancy.
- Latitude (Latitude): Geographic latitude of the area.
- Longitude (Longitude): Geographic longitude of the area.
- Predicted House Price: Predicted house price based on the entered data
- Rounded Prediction: Rounded house price
If you want to predict the value of a house with the following characteristics:
- Median Income: 60 000$
- House Age: 25 years
- Average Rooms: 7
- Average Bedrooms: 3
- Population: 2500 people
- Average Occupancy: 3.5 people
- Latitude: 34.05
- Longitude: -118.25
Then the form will be filled out as follows:
- Median Income: 6.0
- House Age: 25.0
- Average Number of Rooms: 7.0
- Average Number of Bedrooms: 3.0
- Population: 2500.0
- Average Occupancy: 3.5
- Latitude: 34.05
- Longitude: -118.25
- Install the repository
git clone https://github.com/Bebrowskiy/house-price-predictor.git
- Install dependencies
pip install -r requirements.txt
- Train the model
python models/train_model.py
- Run the web application
python run.py
Then, open a web browser and go to http://127.0.0.1:5000/
to start using the application.