Academic / CourseworkMachine Learning~2 min read

Boston House Price Prediction

End-to-end regression pipeline comparing linear and tree models with Flask inference.

RoleML Developer
TimelineAug 2025
DomainMachine Learning
Core StackPython, Scikit-learn, Flask

What I Built#

I developed this project for a university machine learning course to practice taking a regression problem all the way from data analysis to a working web interface.

The application predicts residential property prices from 13 census attributes (like number of rooms, property tax rate, highway accessibility, and pupil-teacher ratios). I trained the models in Python using Scikit-Learn and deployed the inference endpoint using a lightweight Flask web application.

Boston House Price Prediction Web Application
Click to view fullscreen
Boston House Price Prediction Web Application

How It Works#

architecture-diagram.txt
Web Browser Form
       │
       ▼
┌──────────────────────────────┐
│       Flask Web Server       │ (Parses input numbers into a NumPy array)
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│  Serialized Scikit Pipeline  │ (joblib.load('regmodel.pkl'))
│  ├── StandardScaler          │ (Applies pre-fit scaling)
│  └── Regression Estimator    │ (Linear / Ridge / Random Forest)
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│  HTML Template Prediction    │ (Renders estimated price back to user)
└──────────────────────────────┘
  1. 01
    Data Exploration & Cleaning: I analyzed the 13 census features using Pandas, identifying right-skewed variables (like crime rate and highway accessibility) and checking feature correlations against median home prices.
  2. 02
    Model Training & Comparison: I trained and evaluated multiple algorithms:
    • Linear Regression as a baseline.
    • Ridge Regression with L2 regularization to penalize large coefficients on correlated features.
    • Random Forest Regressor to capture non-linear relationships.
  3. 03
    Pipeline Packaging: To ensure web requests don't fail due to missing or mismatched feature scaling, I bundled the StandardScaler and model weights together into a single .pkl file using joblib.
  4. 04
    Flask Interface: A simple HTML form accepts user inputs and passes them to a Flask route (/predict_api and /predict), which returns the estimated property value.
Boston Housing Inference Results & Prediction Output
Click to view fullscreen
Boston Housing Inference Results & Prediction Output

What I Learned#

  • Bundle preprocessing with your model: Saving the scaler alongside the model into a single pipeline file eliminates bugs where raw, unscaled numbers get passed to the estimator during web inference.
  • Visualizing correlations saves time: Plotting correlation heatmaps early on helped me quickly see which features (like number of rooms and lower status population percentage) had the strongest impact on home prices.

Complete Technology Stack

PythonScikit-learnFlaskPandasNumPy