In this tutorial, we'll build a sample application that predicts whether a loan application will be approved and instrument it with Gantry.

By the end of the tutorial you will understand how to:

  • Log training data, production data, and human feedback to a Gantry application
  • Explore your production data in the Gantry dashboard
  • Use the SDK to access all of your data and metrics programmatically

While this tutorial can be successfully completed using only the steps we outline here, if you 'd like access to all the source code mentioned here, please contact us.

To reproduce the material in this tutorial, you will need a Gantry API Key, which requires being added to your organization at Please request that from your internal Gantry support resource or contact us.


To run the tutorial, you'll need to set up a Python virtual environment and install source code and requirements specified below.

Let's start by cloning the repo and stepping into it:

git clone [email protected]:gantry-ml/gantry-intro-tutorial.git
cd gantry-intro-tutorial
gh repo clone gantry-ml/gantry-intro-tutorial
cd gantry-intro-tutorial


Gantry requires Python 3.7 or above

On macOS, you can use the Homebrew package manager to install Python 3.7. You may need to explicitly use python3to make the command below work.

It's certainly optional, but we commend setting up a virtual environment using venvusing Python 3.7 and using it:

python -m venv venv
source venv/bin/activate

With the env virtual environment active, you can install these requirements

pip install -r requirements.txt


Problems with prerequisites

If the pip install fails, try unpinning the versions that are having issues. If that fails, please contact us.

You're now ready to start training your model.

Instrumenting your model

The very first part of establishing baseline performance indicators is instrumenting your model to register your training data.

Obtain an API Key and add it to

You'll need to log into your account for this step. See Getting Your API Key in the sidebar. Once you've copied your API key, paste it into on line 9 as the value for GANTRY_API_KEY, replacing the text you must have a valid api key. Remember to keep the double-quotation-marks around the key.

A few lines of code instrument your model. Below, we focus on the relevant parts of that instrument the model, omitting other code.

from pathlib import Path

from dotenv import dotenv_values

TUTORIAL_ROOT_DIR = Path(__file__).parent.resolve()
ENV_VARS = dotenv_values(TUTORIAL_ROOT_DIR / ".env")

# Gantry settings
GANTRY_API_KEY = "you must have a valid api key"
GANTRY_APPLICATION_NAME = "Gantry_Tutorial_Application"

# Model settings

# Data settings
    (DATA_DIR / "train.csv"),
    (DATA_DIR / "test.csv"),
    (DATA_DIR / "feature_shift.csv"),
    (DATA_DIR / "label_shift.csv"),
FILENAME = DATA_DIR / "loans.json"
FEEDBACK_FILENAME = DATA_DIR / "feedback.json"

Training your model and registering training data

To train the model and register your training data with Gantry, return to venv in the `gantry-tutorial" directory and run the following command:


It should produce output like this:

2022-06-17 11:37:29.868 | INFO     | __main__:train:45 - Fit a model with training accuracy 0.9120750293083235
2022-06-17 11:37:29.870 | INFO     | loan_utils:save_model_and_artifacts:51 - Saved model to ~/gantry-intro-tutorial/model/model.pkl
2022-06-17 11:37:29.870 | INFO     | __main__:train:47 - πŸŽ‰ Model training successful! πŸŽ‰
2022-06-17 11:37:30,108 gantry.logger.client INFO     Track your batch at
2022-06-17 11:37:30,113 gantry.logger.client INFO     Look for batch id: 820088e3-55d5-479b-8dee-c347cb977e93



if you see output like

2022-06-17 13:26:10,180 gantry.logger.stores ERROR    Error during api key check: Authentication error. Ensure that you supplied a working API key by calling gantry.ready(). (Status code: 401)
2022-06-17 13:26:10,180 gantry.logger.main WARNING  Gantry services won't receive traffic. Check if API Key is valid

recheck to make sure you entered your API key correctly.

You can check the jobs page in your application to see your batch being processed. If you haven't changed the name of the application in, the jobs page should be available at


Gantry's job tab, which shows the completed batch job for your entry

Congratulations! You've logged your first set of data to Gantry.

What’s Next