Skip to content

codex-0915/house-price-predictor

Repository files navigation

House Price Predictor

A simple machine learning project with end-to-end MLOps use case: from raw data and move through data preprocessing, feature engineering, experimentation, model tracking with MLflow, and optionally using Jupyter for exploration.

Project Setup

Preparing Your Environment

  1. Setup Python Virtual Environment using UV:

    uv venv --python python3.11
    source .venv/bin/activate
  2. Install dependencies:

    uv pip install -r requirements.txt

Setup MLflow for Experiment Tracking

To track experiments and model runs:

docker-compose -f deployment/mlflow/docker-compose.yml up -d
docker-compose ps

Using Podman? Use this instead:

podman-compose -f deployment/mlflow/docker-compose.yaml up -d
podman-compose ps

Access the MLflow UI at http://localhost:5555


Using JupyterLab (Optional)

If you prefer an interactive experience, launch JupyterLab with:

uv python -m jupyterlab
# or
python -m jupyterlab

Model Workflow

🧹 Step 1: Data Processing

Clean and preprocess the raw housing dataset:

python src/data/run_processing.py   --input data/raw/house_data.csv   --output data/processed/cleaned_house_data.csv

Step 2: Feature Engineering

Apply transformations and generate features:

python src/features/engineer.py   --input data/processed/cleaned_house_data.csv   --output data/processed/featured_house_data.csv   --preprocessor models/trained/preprocessor.pkl

Step 3: Modeling & Experimentation

Train your model and log everything to MLflow:

python src/models/train_model.py   --config configs/model_config.yaml   --data data/processed/featured_house_data.csv   --models-dir models   --mlflow-tracking-uri http://localhost:5555

Building FastAPI and Streamlit App

Building FastAPI

To build and run the FastAPI that the streamlit app will use, run:

podman build -t house-price-predict-fastapi:latest .  # Build the image
podman run -idtp house-price-predict-fastapi         # Run the container

You could test the API with Postman, or using curl using:

curl -X POST "http://localhost:8000/predict" \
-H "Content-Type: application/json" \
-d '{
  "sqft": 1500,
  "bedrooms": 3,
  "bathrooms": 2,
  "location": "suburban",
  "year_built": 2000,
  "condition": "fair"
}'

NOTE: Be sure to replace http://localhost:8000/predict with actual endpoint based on where its running.

Run Streamlit Application with FastAPI

To run the streamlit app with FastAPI, run:

podman-compose build  # Build the image
podman-compose up -d  # Run the streamlit app with Fastapi

About

ML model for predicting house pricing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors