README.md

April 2, 2025 Β· View on GitHub

🏠 Asturias Housing Price Predictor

EspaΓ±ol

Python Scikit-learn Pandas XGBoost


πŸ“ Project Description

This project applies Machine Learning techniques to predict housing prices in Asturias, Spain, using real-world data collected from Idealista.

The dataset includes information such as:

  • Property type
  • Location (neighborhood, municipality, district)
  • Built area (square meters)
  • Number of bedrooms and bathrooms
  • Selling price

The goal is to develop a tool that helps buyers, real estate agents, or analysts to make informed decisions in the property market.


🎯 Objectives

  • 🧠 Predict housing prices based on property features.
  • πŸ“Š Identify the most influential variables affecting price (square meters, location, etc.).
  • βš–οΈ Compare different Machine Learning models to choose the most suitable one.
  • 🌍 Provide a practical solution for analyzing the real estate market in Asturias.

πŸ“‘ Project Structure

πŸ“‚ ML_AsturiasHousingPricePredictor/
β”œβ”€β”€ πŸ“‚ src/
β”‚   β”œβ”€β”€ πŸ“‚ data_sample/
β”‚   β”‚   β”œβ”€β”€ cleaned_dataset.csv
β”‚   β”‚   └── scrap_data_asturias.csv
β”‚   β”œβ”€β”€ πŸ“‚ img/
β”‚   β”‚   β”œβ”€β”€ additional_features.png
β”‚   β”‚   β”œβ”€β”€ correlation_heatmap_extended.png
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ πŸ“‚ models/
β”‚   β”‚   β”œβ”€β”€ xgb_full_model.pkl
β”‚   β”‚   └── xgb_reduced_model.pkl
β”‚   β”œβ”€β”€ πŸ“‚ notebooks/
β”‚   β”‚   β”œβ”€β”€ eda.ipynb
β”‚   β”‚   └── preprocessing.ipynb
β”‚   β”œβ”€β”€ πŸ“‚ results_notebook/
β”‚   β”‚   └── final_results.ipynb
β”‚   └── πŸ“‚ utils/
β”‚       β”œβ”€β”€ bootcampviztools.py
β”‚       └── toolbox_ML.py
β”‚
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
└── requirements.txt

πŸ› οΈ Technologies Used

  • Python
  • Pandas, NumPy
  • Matplotlib, Seaborn
  • Scikit-learn
  • XGBoost, CatBoost, LightGBM
  • Jupyter Notebook

πŸš€ How to Run the Project

  1. Clone the repository:
    git clone https://github.com/apvwbm/ML_AsturiasHousingPricePredictor.git
    cd ML_AsturiasHousingPricePredictor
  2. (Optional) Create a virtual environment:
    python -m venv venv
    source venv/bin/activate # macOS/Linux
    venv\Scripts\activate # Windows
  3. Install the dependencies:
    pip install -r requirements.txt
  4. Explore the notebooks:
    jupyter notebook src/notebooks/*.ipynb
  5. Check the final results:
    jupyter notebook src/results_notebook/final_results.ipynb

πŸ“Š Results

The selected model was XGBoost, trained using only the 7 most influential features according to permutation_importance. It achieved the following results:

  • MAE: €7,446
  • RMSE: €46,321
  • RΒ²: 0.9175

πŸ“Œ This demonstrates that precise and efficient housing price predictions are achievable even with a reduced set of variables.


βœ… Conclusions

  • The model can estimate housing prices in Asturias with an accuracy of 91.7% (RΒ²).
  • Built area and neighborhood location are the most determining factors.
  • The number of features was successfully reduced without sacrificing accuracy, enhancing efficiency.
  • This approach is adaptable to other regions and serves as a basis for automated valuation tools.

πŸ‘€ Author

Aitor PΓ©rez

LinkedIn | GitHub