Skip to main content

How to Set Up and Run the House Price Prediction Project with MLflow and scikit-learn

· 21 min read
Jagdish Kumawat
Founder @ Dewiride

You've downloaded the House Price Prediction source code, and you want to see it working. This post takes you from the zip file to a trained model whose every run you can open in MLflow, one step at a time, with what each step should print.

You don't need to have read the tutorial series first. By the end, you'll have:

  • an MLflow tracking server running on your own computer, with its UI at http://127.0.0.1:8080;
  • the project installed and in Git, so every run records the version of the code that produced it;
  • two trained models, with their settings, a score after every 10 trees, their test scores, a plot and the data each one used, side by side in MLflow;
  • two commands that read the runs back: a leaderboard and a learning curve.

Everything on this page is real output, from a fresh copy of the archive on macOS, in zsh. The PowerShell lines were run in PowerShell 7.6.

Get the Source Code​

Get the complete source code of House Price Prediction with MLflow and scikit-learn on Dewiride Store →

The archive holds everything this post installs and runs. After you buy it, you'll find it in your library on the store, as one zip file.

What You Need​

  • uv. uv installs Python and every package the project needs. If your computer doesn't have Python 3.15, uv downloads it for you.
  • Git. Every run records the Git commit of the code that produced it.
  • A terminal. On macOS or Linux, that's zsh or bash. On Windows, it's PowerShell.
  • An internet connection for the install, about 550 MB of packages, and for the first training run, which downloads the data, under 1 MB.

Check the first two in your terminal:

Terminal
uv --version
git --version
Output
uv 0.13.10 (e3e7c1eac 2026-11-24 aarch64-apple-darwin)
git version 2.56.1

Your numbers can be higher than these.

What it costs: nothing. MLflow, scikit-learn, uv and Python are free and open source, and everything runs on your own computer.

Step 1: Unzip the Archive​

Open a terminal in the folder where you saved the zip file.

Terminal
unzip house-price-prediction-mlflow-scikit-learn-1.0.0.zip
cd house-price-prediction-mlflow-scikit-learn

This is what you've got:

house-price-prediction-mlflow-scikit-learn
├── README.md These same steps, every command and every setting
├── pyproject.toml The project, its packages and its three commands
├── uv.lock The exact version of every package
├── .python-version Python 3.15
├── .env.example The settings, with their defaults
├── .gitignore
└── src/
└── house_price_prediction/
├── train.py The train command
├── curve.py The curve command
├── leaderboard.py The leaderboard command
├── data.py Loads the data and splits it
├── datasets.py Describes each part of the split for MLflow
├── plots.py The predicted-against-actual plot
├── reports.py The tables each run saves
├── config.py The settings
├── code_version.py The Git commit each run records
└── __init__.py

Step 2: Start an MLflow Tracking Server​

The project doesn't keep its runs itself. It sends them to an MLflow tracking server: a small web application that stores every run in a database and shows them in your browser. The server lives in a folder of its own, next to the project. If you already run one for another project of the series, keep it running and go to Step 3.

Go up to the folder that holds the project, and create the server's folder there:

Terminal
cd ..
uv init --bare --python 3.15 mlflow-server
Output
Initialized project `mlflow-server` at `/Users/you/source/mlflow-server`

--bare creates only a pyproject.toml file, because this folder only runs a server. --python 3.15 records that it needs Python 3.15 or newer. Now install MLflow in it:

Terminal
cd mlflow-server
uv add mlflow
Output (excerpt)
Using CPython 3.15.2 interpreter at: /Library/Frameworks/Python.framework/Versions/3.15/bin/python3
Creating virtual environment at: .venv
Resolved 92 packages in 2.37s
Installed 88 packages in 1.01s
...
+ mlflow==3.18.0
+ mlflow-skinny==3.18.0
...

Then start the server:

Terminal
uv run mlflow server --port 8080
Output (excerpt)
Backend store URI not provided. Using sqlite:///mlflow.db
Registry store URI not provided. Using backend store URI.
2026/11/28 15:35:41 INFO mlflow.store.db.utils: Creating initial MLflow database tables...
2026/11/28 15:35:41 INFO mlflow.store.db.utils: Updating database tables
[MLflow] Security middleware enabled with default settings (localhost-only). To allow connections from other hosts, use --host 0.0.0.0 and configure --allowed-hosts and --cors-allowed-origins.
2026/11/28 15:35:42 INFO: Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
...
2026/11/28 15:35:48 INFO: Application startup complete.

A terminal running uv run mlflow server --port 8080: MLflow creates its database tables, enables its security middleware and says Uvicorn running on http://127.0.0.1:8080, then Application startup complete.

Leave this terminal open: the server runs as long as it does. How to Start an MLflow Tracking Server on Your Computer explains every option of mlflow server.

Step 3: Create Your Settings File​

Open a second terminal in the house-price-prediction-mlflow-scikit-learn folder, and copy the example settings to .env, the file the project reads them from:

Terminal 2
cp .env.example .env

Nothing is printed. This is the file you've just made:

.env
# The MLflow tracking server this project sends its runs to.
MLFLOW_TRACKING_URI=http://127.0.0.1:8080
# The MLflow experiment that groups this project's runs.
MLFLOW_EXPERIMENT_NAME=house-price-prediction
# Record the computer's CPU, memory, disk and network use during each run (true or false).
HOUSE_PRICES_LOG_SYSTEM_METRICS=true
# Seconds between two system metrics samples (0.1 or more). A run records none unless it lasts
# longer than one interval, so keep this below your shortest training run.
HOUSE_PRICES_SYSTEM_METRICS_INTERVAL=1

The defaults match the server from Step 2, so there's nothing to change. Git ignores .env, so your own settings never end up in a commit.

Step 4: Install the Packages​

Terminal 2
uv sync
Output (excerpt)
Using CPython 3.15.2 interpreter at: /Library/Frameworks/Python.framework/Versions/3.15/bin/python3.15
Creating virtual environment at: .venv
Resolved 94 packages in 6ms
Built house-price-prediction @ file:///Users/you/source/house-price-prediction-mlflow-scikit-learn
Prepared 1 package in 5ms
Installed 92 packages in 853ms
+ aiohappyeyeballs==2.7.1
+ aiohttp==3.14.5
...
+ zipp==4.1.2

A terminal running uv sync in the project folder: uv creates .venv, builds house-price-prediction and installs 92 packages.

uv sync creates the project's own environment in .venv and installs exactly the versions uv.lock lists, so you get the same packages the project was tested with. It also installs the project itself, which is what makes its three commands, train, curve and leaderboard, work with uv run.

Step 5: Put the Project in Git​

Every run records the Git commit the code is at, so that months later you can still tell which code produced a result. That needs a Git repository:

Terminal 2
git init -b main
Output
Initialized empty Git repository in /Users/you/source/house-price-prediction-mlflow-scikit-learn/.git/
Terminal 2
git add .
git commit -m "House price prediction 1.0.0"
Output
[main (root-commit) 7e0134d] House price prediction 1.0.0
16 files changed, 2442 insertions(+)
create mode 100644 .env.example
create mode 100644 .gitignore
create mode 100644 .python-version
create mode 100644 README.md
create mode 100644 pyproject.toml
create mode 100644 src/house_price_prediction/__init__.py
create mode 100644 src/house_price_prediction/code_version.py
create mode 100644 src/house_price_prediction/config.py
create mode 100644 src/house_price_prediction/curve.py
create mode 100644 src/house_price_prediction/data.py
create mode 100644 src/house_price_prediction/datasets.py
create mode 100644 src/house_price_prediction/leaderboard.py
create mode 100644 src/house_price_prediction/plots.py
create mode 100644 src/house_price_prediction/reports.py
create mode 100644 src/house_price_prediction/train.py
create mode 100644 uv.lock

A terminal running git add . and git commit: the first commit on main, 7e0134d, with the project's 16 files.

.env and .venv aren't in the list: .gitignore keeps them out. If Git asks who you are, How to Create a Git Repository and Make Your First Commit shows how to set your name and email. Your commit's hash, 7e0134d here, will be different.

Step 6: Train Your First Model​

Terminal 2
uv run train --run-name first-run
Output
2026/11/28 15:38:18 INFO mlflow.tracking.fluent: Experiment with name 'house-price-prediction' does not exist. Creating a new experiment.
2026/11/28 15:38:18 INFO house_price_prediction: Loading the California Housing data
2026/11/28 15:38:18 INFO sklearn.datasets._california_housing: Downloading Cal. housing from https://ndownloader.figshare.com/files/5976036 to /Users/you/scikit_learn_data
2026/11/28 15:38:21 INFO mlflow.system_metrics.system_metrics_monitor: Skip logging GPU metrics. Set logger level to DEBUG for more details.
2026/11/28 15:38:21 INFO mlflow.system_metrics.system_metrics_monitor: Started monitoring system metrics.
2026/11/28 15:38:21 INFO house_price_prediction: Training on 13209 rows, scoring on 3303 validation rows
2026/11/28 15:38:21 INFO house_price_prediction: 10 trees: validation RMSE 0.5490
2026/11/28 15:38:21 INFO house_price_prediction: 20 trees: validation RMSE 0.5417
2026/11/28 15:38:21 INFO house_price_prediction: 30 trees: validation RMSE 0.5363
2026/11/28 15:38:21 INFO house_price_prediction: 40 trees: validation RMSE 0.5320
2026/11/28 15:38:21 INFO house_price_prediction: 50 trees: validation RMSE 0.5308
2026/11/28 15:38:22 INFO house_price_prediction: 60 trees: validation RMSE 0.5300
2026/11/28 15:38:22 INFO house_price_prediction: 70 trees: validation RMSE 0.5301
2026/11/28 15:38:22 INFO house_price_prediction: 80 trees: validation RMSE 0.5287
2026/11/28 15:38:22 INFO house_price_prediction: 90 trees: validation RMSE 0.5283
2026/11/28 15:38:22 INFO house_price_prediction: 100 trees: validation RMSE 0.5276
2026/11/28 15:38:23 INFO house_price_prediction: Run first-run: MAE 0.337, RMSE 0.516, R2 0.797
🏃 View run first-run at: http://127.0.0.1:8080/#/experiments/1/runs/ce4616f10a6e405dabf35d68503eb0a5
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/1
2026/11/28 15:38:23 INFO mlflow.system_metrics.system_metrics_monitor: Stopping system metrics monitoring...
2026/11/28 15:38:23 INFO mlflow.system_metrics.system_metrics_monitor: Successfully terminated system metrics monitoring!

A terminal running uv run train --run-name first-run: the data downloads, the validation RMSE falls from 0.5490 at 10 trees to 0.5276 at 100, and the run ends with MAE 0.337, RMSE 0.516, R2 0.797 and its link.

Line by line:

  • Creating a new experiment: the first run creates the house-price-prediction experiment, the group your runs go into.
  • Downloading Cal. housing: scikit-learn downloads the California Housing data once, and keeps it in scikit_learn_data in your home folder. Later runs read that copy.
  • Started monitoring system metrics: MLflow samples CPU, memory, disk and network use every second while the run lasts.
  • 10 trees to 100 trees: the forest grows 10 trees at a time, and after each step it's scored on 3,303 rows it doesn't train on. RMSE is the typical error, in units of $100,000.
  • Run first-run: the final scores, on 4,128 rows kept back for testing. The model is off by about $51,600 on a typical house, and explains about 80% of the variation in prices.

Step 7: Find the Run in MLflow​

Open http://127.0.0.1:8080 in your browser. On a first visit, MLflow opens in GenAI mode, with the MLflow Assistant panel on the right:

The MLflow 3.18.0 home page on a first visit, in GenAI mode, with house-price-prediction and Default under Recent Experiments and the MLflow Assistant Beta panel open on the right.

GenAI mode is for apps built on language models. This project trains a classic model, so:

  1. Click Model training at the top of the sidebar.
  2. Close the MLflow Assistant panel with the X in its top-right corner.

The MLflow home page in Model training mode, with Home, Experiments and Model registry in the sidebar and house-price-prediction under Recent Experiments.

MLflow remembers both choices in your browser. Click house-price-prediction:

The Runs page of the house-price-prediction experiment, with first-run, its training dataset california-housing-train and two more, a duration of 2.1s and its source train.

Click first-run to open the run:

The Overview of first-run: 8 system metrics and 6 model metrics, and under About this run the source train with the Git commit 7e0134d, the california-housing-train dataset and the tags model_type random_forest and dataset california_housing.

Next to Source, 7e0134d is the commit from Step 5: this run came from exactly that code. Below the metrics, Parameters lists every setting the run used. Open the Model metrics tab to see the scores as charts:

The Model metrics tab of first-run: bars for the test scores mae 0.34, r2 0.80 and rmse 0.52, and line charts of val_mae, val_r2 and val_rmse over 10 to 100 trees.

The test scores are bars, because they were logged once. The validation scores are lines, one point per step, so you can see the forest improve as it grows, and see the improvement flatten out after about 50 trees.

Then open Artifacts, then plots, then predicted_vs_actual.png:

The Artifacts tab of first-run with plots/predicted_vs_actual.png open: a scatter plot of predicted against actual median house values around a dashed perfect-prediction line.

Each dot is a test row: the closer it sits to the dashed line, the better the prediction. The column of dots on the right edge is the dataset's highest value, 5.00001, or $500,001, which 965 of its 20,640 rows share. evaluation holds the feature importance table and every test prediction as a CSV file.

Step 8: Train Again and Compare​

Train a second model whose trees may only grow 8 levels deep:

Terminal 2
uv run train --run-name depth-8 --max-depth 8
Output (last lines)
2026/11/28 15:38:34 INFO house_price_prediction: 100 trees: validation RMSE 0.5857
2026/11/28 15:38:34 INFO house_price_prediction: Run depth-8: MAE 0.403, RMSE 0.586, R2 0.738
🏃 View run depth-8 at: http://127.0.0.1:8080/#/experiments/1/runs/4abd5fd82ac14b23826763ef63d83b30
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/1
2026/11/28 15:38:34 INFO mlflow.system_metrics.system_metrics_monitor: Stopping system metrics monitoring...
2026/11/28 15:38:34 INFO mlflow.system_metrics.system_metrics_monitor: Successfully terminated system metrics monitoring!

Now rank the runs. leaderboard lists the finished runs with the lowest validation RMSE first:

Terminal 2
uv run leaderboard
Output
run val_rmse test_rmse trees max_depth seed run_id
first-run 0.5276 0.5157 100 None 42 ce4616f10a6e405dabf35d68503eb0a5
depth-8 0.5857 0.5864 100 8 42 4abd5fd82ac14b23826763ef63d83b30

A terminal running uv run leaderboard: first-run with a validation RMSE of 0.5276 ranks above depth-8 with 0.5857.

Limiting the depth made the model worse here: 0.5857 against 0.5276. --top sets how many runs it shows, and --filter narrows them with an MLflow search condition, such as --filter "params.max_depth = '8'".

curve shows how one run's score changed as its forest grew:

Terminal 2
uv run curve first-run
Output
10 trees val_rmse 0.5490
20 trees val_rmse 0.5417
30 trees val_rmse 0.5363
40 trees val_rmse 0.5320
50 trees val_rmse 0.5308
60 trees val_rmse 0.5300
70 trees val_rmse 0.5301
80 trees val_rmse 0.5287
90 trees val_rmse 0.5283
100 trees val_rmse 0.5276
Best val_rmse: 0.5276 at 100 trees

A terminal running uv run curve first-run: the validation RMSE after each 10 trees, ending with Best val_rmse 0.5276 at 100 trees.

--metric val_mae or --metric val_r2 shows the other two scores. The README lists every option of the three commands.

Stop It, and Start It Again Later​

To stop the server, press Ctrl+C in its terminal:

Output (excerpt)
^CException ignored on threading shutdown:
2026/11/28 15:59:06 INFO: Shutting down
...
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.15/lib/python3.15/threading.py", line 1721, in _shutdown
_thread_shutdown()
~~~~~~~~~~~~~~~~^^
KeyboardInterrupt
...
2026/11/28 15:59:07 INFO: Waiting for child process [71282]
2026/11/28 15:59:07 INFO: Stopping parent process [71276]

The KeyboardInterrupt traceback comes from the server's background job runner, and the server still stops cleanly. Fixed: "Exception ignored on threading shutdown" KeyboardInterrupt When You Stop the MLflow Server explains it, and shows how to turn the job runner off when you don't need it.

Your runs stay in mlflow-server/mlflow.db and mlflow-server/mlartifacts. Next time, start the server from its folder, then work from the project's folder in a second terminal, for example with the leaderboard from Step 8:

Terminal (in mlflow-server)
uv run mlflow server --port 8080
Terminal 2 (in house-price-prediction-mlflow-scikit-learn)
uv run leaderboard

Find Your Way Around the Code​

To changeLook in
What a run recordstrain.py: the parameters, the step and test metrics, the plot and the tables
The modeltrain.py, where it builds the RandomForestRegressor
How the data is splitdata.py, and the --test-size, --validation-size and --random-state options
The plotplots.py
The tables a run savesreports.py
The leaderboard's columns or its sort orderleaderboard.py
Where the runs goMLFLOW_TRACKING_URI and MLFLOW_EXPERIMENT_NAME in .env

Before You Go to Production​

What you've just run is a tracking server for one person, on one computer. Part 10 of the series goes through the whole checklist. In short:

Common Mistakes​

MistakeWhat happensDo this instead
Skipping Step 5Each run says Found no Git commit for the project, so the run won't record one, and records no commitPut the folder in Git and commit, then train
Training while the server isn't runningThe run fails to reach 127.0.0.1:8080Start the server first, in its own terminal
Starting the server on port 5000 on a MacThe browser shows "Access to localhost was denied"Use --port 8080, as in Step 2
Running an mlflow command, such as mlflow runs describe, without --env-file .envThe command uses a new local database, and can't find your runsAdd --env-file .env

Troubleshooting​

SymptomLikely causeFix
MlflowException: API request to … failed with exception … Max retries exceededThe server isn't running, or runs on another portFixed: "MlflowException: API request to … failed with exception … Max retries exceeded" Connection Refused in MLflow
"Access to localhost was denied" in the browserSomething else, such as AirPlay Receiver, answers on that portFixed: "Access to localhost was denied" HTTP ERROR 403 When You Open the MLflow UI on a Mac
MlflowException: Run with id=… not found from an mlflow commandThe command didn't read .envFixed: "MlflowException: Run with id=… not found" When You Run an MLflow CLI Command
The UI shows Traces and Evaluation menus, and no runsIt's in GenAI modeClick Model training at the top of the sidebar
Exception ignored on threading shutdown and a KeyboardInterrupt traceback when you stop the serverCtrl+C interrupts the server's background job runnerNothing to fix: Fixed: "Exception ignored on threading shutdown" KeyboardInterrupt When You Stop the MLflow Server

FAQ​

Do I need to read the tutorial series first?​

No. This post is all you need to run the project. The series explains how each piece works, from Part 1 to Part 4 for this project.

Can I use another port?​

Yes. Start the server with your port, and change MLFLOW_TRACKING_URI in .env to match, such as http://127.0.0.1:8090.

Does it run on Windows?​

The steps are the same in PowerShell: only unzipping the archive and copying the settings file differ, and both have a PowerShell tab above. I ran those two in PowerShell 7.6 on macOS, not on Windows.

Can I turn off the data MLflow sends?​

Yes. MLflow sends anonymous usage data to its developers by default. How to Turn Off MLflow Telemetry shows how to turn it off.

Conclusion​

From the zip file to a trained model took six steps: unzip, start a tracking server, create .env, run uv sync, commit, and train. first-run scored an RMSE of 0.516 on its test rows, recorded the commit 7e0134d, and saved its scores, settings, data, plot and tables in MLflow, where leaderboard and curve read them back.

Additional Resources​