Skip to main content

How to Set Up and Run the Term Deposit Prediction Project with MLflow and scikit-learn

· 19 min read
Jagdish Kumawat
Founder @ Dewiride

You've downloaded the Term Deposit Prediction source code, and you want to see it working. This post takes you from the zip file to a finished hyperparameter search that MLflow has recorded as one parent run with a child run for each of the best candidates, 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 search records the version of the code that ran it;
  • a search over 9 combinations of settings, each scored with 5-fold cross-validation, filed in MLflow as one parent run and 5 child runs;
  • the best settings, and how well they predict customers the search never saw.

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 Term Deposit 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 search, which downloads the data, about 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. The dataset is free to use under its CC BY 4.0 licence.

Step 1: Unzip the Archive​

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

Terminal
unzip term-deposit-prediction-mlflow-scikit-learn-1.0.0.zip
cd term-deposit-prediction-mlflow-scikit-learn

This is what you've got:

term-deposit-prediction-mlflow-scikit-learn
├── README.md These same steps, the search and every setting
├── pyproject.toml The project, its packages and its tune command
├── uv.lock The exact version of every package
├── .python-version Python 3.15
├── .env.example The settings, with their defaults
├── .gitignore
└── src/
└── term_deposit_prediction/
├── tune.py The tune command: the search and its test score
├── model.py The model the search tunes
├── data.py Downloads the data once, checks it and splits it
├── 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 1.57s
Installed 88 packages in 811ms
...
+ 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 16:07:08 INFO mlflow.store.db.utils: Creating initial MLflow database tables...
2026/11/28 16:07:08 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 16:07:09 INFO: Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
...
2026/11/28 16:07:11 INFO: Application startup complete.

A terminal running uv run mlflow server --port 8080 for a new server: 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 term-deposit-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=term-deposit-prediction
# The folder that keeps the downloaded dataset, relative to the project folder.
TERM_DEPOSIT_DATA_DIR=data

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 5ms
Built term-deposit-prediction @ file:///Users/you/source/term-deposit-prediction-mlflow-scikit-learn
Prepared 1 package in 4ms
Installed 91 packages in 847ms
+ aiohappyeyeballs==2.7.1
...
+ zipp==4.1.2

A terminal running uv sync in the project folder: uv creates .venv, builds term-deposit-prediction and installs 91 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 tune command 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/term-deposit-prediction-mlflow-scikit-learn/.git/
Terminal 2
git add .
git commit -m "Term deposit prediction 1.0.0"
Output
[main (root-commit) 612e0ab] Term deposit prediction 1.0.0
12 files changed, 2182 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/term_deposit_prediction/__init__.py
create mode 100644 src/term_deposit_prediction/code_version.py
create mode 100644 src/term_deposit_prediction/config.py
create mode 100644 src/term_deposit_prediction/data.py
create mode 100644 src/term_deposit_prediction/model.py
create mode 100644 src/term_deposit_prediction/tune.py
create mode 100644 uv.lock

A terminal running git add . and git commit: the first commit on main, 612e0ab, with the project's 12 files.

.env and .venv aren't in the list: .gitignore keeps them out, and the data folder the first search creates is ignored too. 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, 612e0ab here, will be different.

Terminal 2
uv run tune --run-name first-search
Output
2026/11/28 15:41:51 INFO mlflow.tracking.fluent: Experiment with name 'term-deposit-prediction' does not exist. Creating a new experiment.
2026/11/28 15:41:59 INFO term_deposit_prediction: Loading the Bank Marketing data
2026/11/28 15:41:59 INFO term_deposit_prediction.data: Downloading the Bank Marketing data from https://archive.ics.uci.edu/static/public/222/bank+marketing.zip
2026/11/28 15:42:27 INFO term_deposit_prediction: Trying 9 candidates with 5-fold cross-validation on 32950 calls
/Users/you/source/term-deposit-prediction-mlflow-scikit-learn/.venv/lib/python3.15/site-packages/sklearn/metrics/_classification.py:3424: FutureWarning: `y_pred` was renamed to `y_proba` in version 1.9 and will be removed in 1.11. Use `y_proba` instead.
warnings.warn(
2026/11/28 15:42:40 INFO mlflow.sklearn.utils: Logging the 5 best runs, 4 runs will be omitted.
🏃 View run unequaled-hen-32 at: http://127.0.0.1:8080/#/experiments/2/runs/3716c82b04054c62853660d05f7f0c4d
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/2
🏃 View run valuable-tern-474 at: http://127.0.0.1:8080/#/experiments/2/runs/d30a209008b140dfbb36d68a88a6e514
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/2
🏃 View run sincere-shrimp-736 at: http://127.0.0.1:8080/#/experiments/2/runs/a3a73da4efe34d779ae24f13ea321447
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/2
🏃 View run flawless-moose-125 at: http://127.0.0.1:8080/#/experiments/2/runs/044fdfd2114547c4b40b3fa6371a176b
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/2
🏃 View run defiant-midge-910 at: http://127.0.0.1:8080/#/experiments/2/runs/1b875e6bda8f4a4688d7baa339d943b0
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/2
2026/11/28 15:42:41 INFO term_deposit_prediction: Run first-search: best {'model__learning_rate': 0.1, 'model__max_leaf_nodes': 15}, cross-validation ROC AUC 0.7998, test ROC AUC 0.8145
🏃 View run first-search at: http://127.0.0.1:8080/#/experiments/2/runs/eb9baede343249bb91212733d10f52aa
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/2

A terminal running uv run tune --run-name first-search: the data downloads, 9 candidates are tried with 5-fold cross-validation on 32950 calls, MLflow logs the 5 best as child runs, and first-search ends with the best settings, a cross-validation ROC AUC of 0.7998 and a test ROC AUC of 0.8145.

Line by line:

  • Creating a new experiment: the first search creates the term-deposit-prediction experiment, the group your runs go into. I ran all three projects of the series against one server, so it's experiment 2 here; on your server, the number may differ.
  • Downloading the Bank Marketing data: the project downloads the dataset once into its data folder, checks its SHA-256 fingerprint, and reads that copy from then on.
  • Trying 9 candidates: 3 learning rates times 3 tree sizes, each scored by its ROC AUC on 5 different splits of 32,950 calls. 20% of the calls are kept back and never seen by the search.
  • FutureWarning: scikit-learn warns about an old argument name in a call MLflow's autologging makes. It changes nothing in the results, and MLflow has fixed it for a later release (mlflow/mlflow#28012).
  • Logging the 5 best runs: MLflow gives the 5 best candidates a child run each, with names it makes up, such as unequaled-hen-32.
  • Run first-search: the best settings, their cross-validation ROC AUC, and the ROC AUC of the best model on the calls the search never saw: 0.8145. A score of 0.5 would be guessing, and 1.0 perfect.

Step 7: Find the Search in MLflow​

Open http://127.0.0.1:8080 in your browser. On your first visit, MLflow opens in GenAI mode, with the MLflow Assistant panel on the right. Recent Experiments lists every experiment on the server: here the two other projects of the series as well, because they share it.

The MLflow 3.18.0 home page on a first visit, in GenAI mode, with shopper-purchase-prediction, term-deposit-prediction, 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 tunes 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 term-deposit-prediction under Recent Experiments.

MLflow remembers both choices in your browser. Click term-deposit-prediction. The runs page shows one row, first-search, with a + before its name: click the + to show its child runs:

The Runs page of term-deposit-prediction with first-search expanded: its five child runs flawless-moose, defiant-midge, unequaled-hen, sincere-shrimp and valuable-tern, each on the same training dataset, with the source tune.

Each child run holds one candidate: its settings, and its scores across the 5 folds as mean_test_score, std_test_score and rank_test_score. Click first-search to open the parent run:

The Overview of first-search: 9 metrics, including best_cv_score 0.7998 and test_roc_auc 0.8145, the five child runs under About this run, the source tune with the Git commit 612e0ab, the training dataset and the tags estimator_name GridSearchCV.

  • best_cv_score is the best candidate's cross-validation ROC AUC, and test_roc_auc its score on the calls the search never saw.
  • training_… metrics are the best model's scores on the calls it trained on, so they're higher than the honest test score.
  • Child runs links to the five candidates, and Source shows the commit from Step 5.
  • Parameters, further down, lists the search's own settings and the best values, as best_model__learning_rate and best_model__max_leaf_nodes.
  • Artifacts holds cv_results.csv, the score of every candidate on every fold, and plots of the best model's training confusion matrix, ROC curve and precision-recall curve.

Stop It, and Start It Again Later​

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

Output (excerpt)
^CTraceback (most recent call last):
File "<frozen runpy>", line 201, in _run_module_as_main
File "<frozen runpy>", line 87, in _run_code
File "/Users/you/source/mlflow-server/.venv/lib/python3.15/site-packages/mlflow/server/jobs/_job_runner.py", line 49, in <module>
time.sleep(10) # wait for huey consumer launching
~~~~~~~~~~^^^^
KeyboardInterrupt
2026/11/28 16:07:14 INFO: Shutting down
...
2026/11/28 16:07:14 INFO: Stopping parent process [91461]

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 the downloaded data in the project's data folder. Next time, start the server from its folder. Your searches are still there in the UI, and uv run tune with a new --run-name adds another one:

Terminal (in mlflow-server)
uv run mlflow server --port 8080

Find Your Way Around the Code​

To changeLook in
The settings the search triesPARAM_GRID in tune.py
The number of folds, the share kept back for testing, the seedCV_FOLDS, TEST_SIZE and RANDOM_STATE in tune.py
How many candidates get a child runThe --max-tuning-runs option, 5 by default
The modelmodel.py: the text columns are one-hot encoded, then a HistGradientBoostingClassifier predicts
Which columns the model may usedata.py, which leaves out the length of the call
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 search
Searching 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
Reading the training_… metrics as the model's qualityThey're scores on the data it learned from, so they look better than they areJudge the model by best_cv_score and test_roc_auc

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
The runs page shows only first-searchThe child runs are folded under itClick the + before its name
Exception ignored on threading shutdown or another 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. Part 5 of the series explains how the search and its autologging work.

Why is there no model file?​

The search is about choosing settings, so autologging is told not to save models. Each run records the settings and the scores, which is what you compare.

Why does the project leave out the length of the call?​

The length of a call isn't known until the call is over, and by then the customer has answered. The dataset's own notes point that out, so a model that's meant to be used before a call can't rely on it.

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.

Conclusion​

From the zip file to a finished search took six steps: unzip, start a tracking server, create .env, run uv sync, commit, and run tune. first-search tried 9 combinations of settings with 5-fold cross-validation, filed the 5 best as child runs, and found that a learning rate of 0.1 with 15 leaves per tree predicts unseen customers with a ROC AUC of 0.8145.

Additional Resources​