• Documentation
    • About ​ValidMind
    • Get Started
    • Guides
    • Support
    • Releases

    • ValidMind Library
    • Python API
    • Public REST API

    • Training Courses
  • Log In
  1. Quickstart (individual tests)
  • ValidMind Library
  • Supported records and frameworks

  • Quickstart
  • Quickstart for documentation
  • Quickstart for validation
  • Quickstart (OIDC device flow)
  • Quickstart (individual tests)
  • Install and initialize ValidMind
    • Install and initialize the library
    • Authenticate with OIDC device flow
    • Install and initialize the library for R
    • Use an HTTP proxy with the library
  • Store credentials in .env files

  • End-to-End Tutorials
  • Development
    • 1 — Set up ValidMind Library
    • 2 — Start the development process
    • 3 — Integrate custom tests
    • 4 — Finalize testing & documentation
  • Validation
    • 1 — Set up ValidMind Library for validation
    • 2 — Start the validation process
    • 3 — Developing a challenger
    • 4 — Finalize validation & reporting

  • How-To
  • Run tests & test suites
    • Explore tests
      • Explore tests
      • Explore test suites
    • Run tests
      • Run dataset-based tests
      • Run comparison tests
      • Configuring tests
        • Configure judge LLM and judge embeddings
        • Customize test result descriptions
        • Enable PII detection in tests
        • Dataset Column Filters when Running Tests
        • Run tests with multiple datasets
        • Understand and utilize RawData in ValidMind tests
      • Using tests in documentation
        • Document multiple results for the same test
        • Run individual documentation sections
        • Run documentation tests with custom configurations
    • Custom tests
      • Implement custom tests
      • Integrate external test providers
  • Use library features
    • Data and datasets
      • Introduction to ValidMind Dataset and Model Objects
      • Dataset inputs
        • Configure dataset features
        • Load dataset predictions
    • Metrics
      • Log metrics over time
      • Intro to Unit Metrics
    • Qualitative text
      • Generate qualitative text with the ValidMind library
    • Scoring
      • Intro to Assign Scores

  • Notebooks
  • Code samples
    • Agents
      • Document an agentic AI system
    • Capital markets
      • Quickstart for knockout option pricing model documentation
      • Quickstart for Heston option pricing model using QuantLib
    • Code explainer
      • Quickstart for model code documentation
    • Credit risk
      • Document an application scorecard model
      • Document an application scorecard model
      • Document a credit risk model
      • Document an application scorecard model
      • Document an Excel-based application scorecard model
    • NLP and LLM
      • Sentiment analysis of financial data using a large language model (LLM)
      • Summarization of financial data using a large language model (LLM)
      • Sentiment analysis of financial data using Hugging Face NLP models
      • Summarization of financial data using Hugging Face NLP models
      • Automate news summarization using LLMs
      • Prompt validation for large language models (LLMs)
      • RAG Model Benchmarking Demo
      • RAG Model Documentation Demo
    • Ongoing monitoring
      • Ongoing Monitoring for Application Scorecard
      • Quickstart for ongoing monitoring of models with ValidMind
    • Regression
      • Document a California Housing Price Prediction regression model
    • Time series
      • Document a time series forecasting model
      • Document a time series forecasting model
    • Validation
      • Validate an application scorecard model

  • Reference
  • ​ValidMind test sandbox
  • ValidMind Library Python API
  • ValidMind Public REST API

On this page

  • Introduction
  • About ValidMind
    • Before you begin
    • New to ValidMind?
    • Key concepts
  • Setting up
    • Install the ValidMind Library
    • Initialize the ValidMind Library
    • Initialize the Python environment
  • Getting to know ValidMind
    • View documentation in the ValidMind Platform
  • Working with ValidMind datasets
    • Prepare the sample dataset
    • Initialize the ValidMind datasets
  • Working with ValidMind models
    • Train an XGBoost classifier model
    • Initialize the ValidMind model
    • Assign predictions
  • Run and log individual tests
    • Run and log a set of tests
  • In summary
  • Next steps
    • Work with your documentation
    • Discover more learning resources
  • Upgrade ValidMind
  • Edit this page
  • Report an issue

Quickstart for documentation with individual tests

Learn the basics of using ValidMind to document records as part of a development workflow. Set up the ValidMind Library in your environment, then run individual tests and log their results to a document that has no content blocks registered yet.

To document our model with the ValidMind Library, we'll:

  1. Import a sample dataset and preprocess it
  2. Split the datasets and initialize them for use with ValidMind
  3. Initialize a ValidMind model object for use with testing
  4. Run individual tests with vm.tests.run_test() and log each result to the ValidMind Platform with result.log()

Introduction

Development aims to produce a fit-for-purpose champion by conducting thorough testing and analysis, supporting the capabilities of the champion with evidence in the form of documentation and test results. Documentation should be clear and comprehensive, ideally following a structure or template covering all aspects of compliance with risk regulation.

A binary classification model is a type of predictive model used in churn analysis to identify customers who are likely to leave a service or subscription by analyzing various behavioral, transactional, and demographic factors.

  • This model helps businesses take proactive measures to retain at-risk customers by offering personalized incentives, improving customer service, or adjusting pricing strategies.
  • Effective validation of a churn prediction model ensures that businesses can accurately identify potential churners, optimize retention efforts, and enhance overall customer satisfaction while minimizing revenue loss.

About ValidMind

ValidMind is a suite of tools for managing risk, including risk associated with AI and statistical models.

You use the ValidMind Library to automate documentation and validation tests, and then use the ValidMind Platform to collaborate on documentation. Together, these products simplify risk management, facilitate compliance with regulations and institutional standards, and enhance collaboration between yourself and validators.

Before you begin

This notebook assumes you have basic familiarity with Python, including an understanding of how functions work. If you are new to Python, you can still run the notebook but we recommend further familiarizing yourself with the language.

If you encounter errors due to missing modules in your Python environment, install the modules with pip install, and then re-run the notebook. For more help, refer to Installing Python Modules.

New to ValidMind?

If you haven't already seen our documentation on the ValidMind Library, we recommend you begin by exploring the available resources in this section. There, you can learn more about documenting records such as models and running tests, as well as find code samples and our Python Library API reference.

For access to all features available in this notebook, you'll need access to a ValidMind account.

Register with ValidMind

Key concepts

record: A tool tracked in the ValidMind inventory, such as a model. Records include traditional statistical models, legacy systems, artificial intelligence/machine learning models, large language models (LLMs), agentic AI systems, and other documentable items that benefit from oversight, testing, and lifecycle management.

model: SR 26-2 (which supersedes SR 11-7) defines a model as a "complex quantitative method, system, or approach that applies statistical, economic, or financial theories to process input data into quantitative estimates." Simple arithmetic, deterministic rule-based processes, or software without statistical, economic, or financial theories underpinning their design or use are generally outside SR 26-2’s definition of a model. Within ValidMind, a model is a type of record tracked in the inventory.

documentation, model documentation: A structured and detailed document pertaining to a record, encompassing key components such as its underlying assumptions, methodologies, data sources, inputs, performance metrics, evaluations, limitations, and intended uses. Within the realm of risk management, this documentation serves to ensure transparency, adherence to regulatory requirements, and a clear understanding of potential risks associated with the record's application.

document template: Lays out the structure of documents, segmented into various sections and sub-sections, and functions as a test suite specifying the tests that should be run, and how the results should be displayed. Document templates help automate your development, validation, monitoring, and other risk management processes. Document templates are available for default ValidMind document types as well as custom document types.

documentation template: A default ValidMind document type that serves as a standardized framework for developing and documenting records, including sections designated for record details, data descriptions, test results, and performance metrics. By outlining required documentation and recommended analyses, document templates ensure consistency and completeness across documentation and help guide developers through a systematic development process while promoting comparability and traceability of development outcomes.

test: A function contained in the ValidMind Library, designed to run a specific quantitative test on the dataset or record. Test results are logged to the ValidMind Platform, where they are attached to documents. Tests are the building blocks of ValidMind, used to evaluate and document records and datasets, and can be run individually or as part of a suite defined by your templates.

inputs: Objects to be evaluated and documented in the ValidMind Library. They can be any of the following:

  • model: A single record that has been initialized in ValidMind with init_model(). Despite the naming convention, model objects can be any type of record you want to test, document, validate, or monitor with ValidMind.
  • dataset: A single dataset that has been initialized in ValidMind with init_dataset().
  • models: A list of ValidMind records - usually this is used when you want to compare multiple records in your custom tests.
  • datasets: A list of ValidMind datasets - usually this is used when you want to compare multiple datasets in your custom tests. (Learn more: Run tests with multiple datasets)

parameters: Additional arguments that can be passed when running a ValidMind test, used to pass additional information to a test, customize its behavior, or provide additional context.

outputs: Custom tests can return elements like tables or plots. Tables may be a list of dictionaries (each representing a row) or a pandas DataFrame. Plots may be matplotlib or plotly figures.

Setting up

Install the ValidMind Library

Recommended Python versions

Python 3.8 <= x <= 3.14

To install the library, with the xgboost extra for our model and the explainability extra for the SHAP test we run later:

%pip install -q "validmind[xgboost,explainability]"

Initialize the ValidMind Library

Register sample model

Let's first register a sample record (model) for use with this notebook:

  1. In a browser, log in to ValidMind.

  2. In the left sidebar, select Inventory.

  3. Select Model by clicking on {Record} Inventory, where {Record} is the currently active type of record. (Learn more: Register records in the inventory)

  4. Click + Register Model.

  5. Enter the model details and click Next > to continue to assignment of inventory record stakeholders.

  6. Select your own name under the Record Owner drop-down.

  7. Click Register Model to add the model to your inventory.

Create an empty document

Once you've registered your model, let's create a document to hold your test results.

  1. In the left sidebar that appears for your model, click Documents and select Development.

    If you cannot locate your Development document, make sure Development type documents are enabled for model records and create a new document. (Learn more: Manage documents)

  2. Leave the document empty — do not apply a template.

Unlike the standard quickstart, which relies on a template to define which tests run and where their results land, here we log each test result directly. Results logged this way are attached to the document even though no content blocks are registered for them, and you can insert them into the document later from the platform.

Get your code snippet

Initialize the ValidMind Library with the code snippet unique to each record per document, ensuring your test results are uploaded to the correct record and automatically populated in the right document in the ValidMind Platform when you run the library.

  1. On the left sidebar that appears for your model, select Getting Started and select Development from the Document drop-down menu.

  2. Click Copy snippet to clipboard.

  3. Next, load your model identifier credentials from an .env file or replace the placeholder with your own code snippet:

If your organization authenticates with OAuth 2.0 / OIDC instead of API keys, see Authenticate with OIDC device flow or try the OIDC device-flow quickstart notebook.

# Load your model identifier credentials from an `.env` file

%load_ext dotenv
%dotenv .env

# Or replace with your code snippet

import validmind as vm

vm.init(
    # api_host="...",
    # api_key="...",
    # api_secret="...",
    # model="...",
    document="documentation",
)

Initialize the Python environment

Then, let's import the necessary libraries and set up your Python environment for data analysis:

  • Import Extreme Gradient Boosting (XGBoost) with an alias so that we can reference its functions in later calls. XGBoost is a powerful machine learning library designed for speed and performance, especially in handling structured or tabular data.
  • Enable matplotlib, a plotting library used for visualizing data. Ensures that any plots you generate will render inline in our notebook output rather than opening in a separate window.
import xgboost as xgb

%matplotlib inline

Getting to know ValidMind

View documentation in the ValidMind Platform

Next, let's head to the ValidMind Platform to look at the document you created:

  1. In a browser, log in to ValidMind.

  2. In the left sidebar, navigate to Inventory and select the model you registered for this notebook.

  3. Click Development under Documents for your model. The document is still empty, since no content blocks are registered. The test results you log later in this notebook are attached to it.

Working with ValidMind datasets

Prepare the sample dataset

Import the sample dataset

First, let's import the public Bank Customer Churn Prediction dataset from Kaggle so that we have something to work with.

In our below example, note that:

  • The target column, Exited has a value of 1 when a customer has churned and 0 otherwise.
  • The ValidMind Library provides a wrapper to automatically load the dataset as a Pandas DataFrame object. A Pandas Dataframe is a two-dimensional tabular data structure that makes use of rows and columns.
  • To keep the notebook quick to run, we only use the first 500 rows. Remove .head(500) to work with the full dataset, as the standard quickstart does.
from validmind.datasets.classification import customer_churn

print(
    f"Loaded demo dataset with: \n\n\t• Target column: '{customer_churn.target_column}' \n\t• Class labels: {customer_churn.class_labels}"
)

raw_df = customer_churn.load_data().head(500)
raw_df.head()

Preprocess the raw dataset

Before running tests with ValidMind, we'll need to preprocess our imported dataset. This involves splitting the data and separating the features (inputs) from the targets (outputs).

Split the dataset

Splitting our dataset helps assess how well the model generalizes to unseen data.

Use preprocess() to split our dataset into three subsets:

  1. train_df — Used to train the model.
  2. validation_df — Used to evaluate the model's performance during training.
  3. test_df — Used later on to asses the model's performance on new, unseen data.
train_df, validation_df, test_df = customer_churn.preprocess(raw_df)

Separate features and targets

To train the model, we need to provide it with:

  1. Inputs — Features such as customer age, usage, etc.
  2. Outputs (Expected answers/labels) — in our case, we would like to know whether the customer churned or not.

Here, we'll use x_train and x_val to hold the input data (features), and y_train and y_val to hold the answers (the target we want to predict):

x_train = train_df.drop(customer_churn.target_column, axis=1)
y_train = train_df[customer_churn.target_column]
x_val = validation_df.drop(customer_churn.target_column, axis=1)
y_val = validation_df[customer_churn.target_column]

Initialize the ValidMind datasets

Before you can run tests with your preprocessed datasets, you must first initialize a ValidMind Dataset object using the init_dataset function from the ValidMind (vm) module. This step is always necessary every time you want to connect a dataset to documentation and produce test results through ValidMind, but you only need to do it once per dataset.

For this example, we'll pass in the following arguments:

  • dataset — The raw dataset that you want to provide as input to tests.
  • input_id — A unique identifier that allows tracking what inputs are used when running each individual test.
  • target_column — A required argument if tests require access to true values. This is the name of the target column in the dataset.
  • class_labels — An optional value to map predicted classes to class labels.
# Initialize the raw dataset
vm_raw_dataset = vm.init_dataset(
    dataset=raw_df,
    input_id="raw_dataset",
    target_column=customer_churn.target_column,
    class_labels=customer_churn.class_labels,
)

# Initialize the training dataset
vm_train_ds = vm.init_dataset(
    dataset=train_df,
    input_id="train_dataset",
    target_column=customer_churn.target_column,
)

# Initialize the testing dataset
vm_test_ds = vm.init_dataset(
    dataset=test_df,
    input_id="test_dataset",
    target_column=customer_churn.target_column
)

Working with ValidMind models

Train an XGBoost classifier model

Next, let's create an XGBoost classifier model that will automatically stop training if it doesn’t improve after 10 tries.

Setting a threshold avoids wasting time and helps prevent overfitting by stopping training when further improvement isn’t happening.

model = xgb.XGBClassifier(early_stopping_rounds=10)

Set evaluation metrics

Then, we'll set the evaluation metrics, which tells the model to use three different ways to measure its performance:

  1. error — Measures how often the model makes incorrect predictions.
  2. logloss — Indicates how confident the predictions are.
  3. auc — Evaluates how well the model distinguishes between churn and not churn.

Using multiple metrics gives a more complete picture of how good (or bad) the model is.

model.set_params(
    eval_metric=["error", "logloss", "auc"],
)

Fit the model

Finally, our actual training step — where the model learns patterns from the data, so it can make predictions later:

  • The model is trained on x_train and y_train, and evaluates its performance using x_val and y_val to check if it’s learning well.
  • To turn off printed output while training, we'll set verbose to False.
model.fit(
    x_train,
    y_train,
    eval_set=[(x_val, y_val)],
    verbose=False,
)

Initialize the ValidMind model

You'll also need to initialize a ValidMind model object (vm_model) that can be passed to other functions for analysis and tests on the data for our model.

  • Despite the naming convention, ValidMind model objects can be any type of record you want to test, document, validate, or monitor with the ValidMind Library.
  • From classical statistical and machine learning models, to generative and agentic AI systems and more, the ValidMind model object provides a consistent wrapper around your record so it can be passed as a unified input to any ValidMind test or test suite, with results sent directly to the ValidMind Platform.

Initialize your model object with vm.init_model():

vm_model = vm.init_model(
    model,
    input_id="model",
)

Assign predictions

Once the model has been registered, you can assign model predictions to the training and testing datasets.

  • The assign_predictions() method from the Dataset object can link existing predictions to any number of models.
  • This method links the model's class prediction values and probabilities to our vm_train_ds and vm_test_ds datasets.

If no prediction values are passed, the method will compute predictions automatically:

vm_train_ds.assign_predictions(
    model=vm_model,
)

vm_test_ds.assign_predictions(
    model=vm_model,
)

Run and log individual tests

This is where it all comes together — you are now ready to run tests one at a time and log their results.

  • vm.tests.run_test() runs a single test and returns a TestResult object. Nothing is sent to the ValidMind Platform at this point, so you can inspect the result and re-run the test with different inputs or parameters until you're happy with it.
  • result.log() then uploads that result to the document you initialized above.

Since this document has no test-driven blocks telling the library which tests to run, you choose the tests yourself and name each one explicitly.

To explore what's available, use vm.tests.list_tests(). For example, the following lists tests whose ID, task or tags mention classification. A filter only narrows the list, so it won't necessarily include every test you run below. To learn how to search, filter and inspect tests in more detail, see Explore tests.

vm.tests.list_tests(filter="classification", pretty=True)

Run and log a set of tests

Since each test is just a function call, you can run and log several tests with a plain Python loop. The tests below cover data quality, descriptive statistics and correlations, model training, model evaluation, explainability and model diagnosis for our churn model. Each test gets the inputs that suit it:

  • Tests that only need a dataset use the raw dataset.
  • Tests that need a model and a dataset use the test dataset.
  • Tests that compare datasets use the training and test datasets.
  • ClassifierPerformance runs twice, once on the training dataset and once on the test dataset. The :in_sample and :out_of_sample suffixes on the test ID keep the two results separate.
both = [vm_train_ds, vm_test_ds]
tests = {
    # Data description
    "validmind.data_validation.DatasetDescription": {"dataset": vm_raw_dataset},
    "validmind.data_validation.ClassImbalance": {"dataset": vm_raw_dataset},
    "validmind.data_validation.Duplicates": {"dataset": vm_raw_dataset},
    "validmind.data_validation.HighCardinality": {"dataset": vm_raw_dataset},
    "validmind.data_validation.MissingValues": {"dataset": vm_raw_dataset},
    "validmind.data_validation.Skewness": {"dataset": vm_raw_dataset},
    "validmind.data_validation.UniqueRows": {"dataset": vm_raw_dataset},
    "validmind.data_validation.TooManyZeroValues": {"dataset": vm_raw_dataset},
    "validmind.data_validation.IQROutliersTable": {"dataset": vm_raw_dataset},
    "validmind.data_validation.IQROutliersBarPlot": {"dataset": vm_raw_dataset},
    # Descriptive statistics / correlations
    "validmind.data_validation.DescriptiveStatistics": {"dataset": vm_raw_dataset},
    "validmind.data_validation.PearsonCorrelationMatrix": {"dataset": vm_raw_dataset},
    "validmind.data_validation.HighPearsonCorrelation": {"dataset": vm_raw_dataset},
    # Model training
    "validmind.model_validation.ModelMetadata": {"model": vm_model},
    "validmind.data_validation.DatasetSplit": {"datasets": both},
    "validmind.model_validation.sklearn.PopulationStabilityIndex": {"model": vm_model, "datasets": both},
    # Model evaluation
    "validmind.model_validation.sklearn.ConfusionMatrix": {"model": vm_model, "dataset": vm_test_ds},
    "validmind.model_validation.sklearn.ClassifierPerformance:in_sample": {"model": vm_model, "dataset": vm_train_ds},
    "validmind.model_validation.sklearn.ClassifierPerformance:out_of_sample": {"model": vm_model, "dataset": vm_test_ds},
    "validmind.model_validation.sklearn.PrecisionRecallCurve": {"model": vm_model, "dataset": vm_test_ds},
    "validmind.model_validation.sklearn.ROCCurve": {"model": vm_model, "dataset": vm_test_ds},
    "validmind.model_validation.sklearn.TrainingTestDegradation": {"model": vm_model, "datasets": both},
    "validmind.model_validation.sklearn.MinimumAccuracy": {"model": vm_model, "dataset": vm_test_ds},
    "validmind.model_validation.sklearn.MinimumF1Score": {"model": vm_model, "dataset": vm_test_ds},
    "validmind.model_validation.sklearn.MinimumROCAUCScore": {"model": vm_model, "dataset": vm_test_ds},
    # Explainability
    "validmind.model_validation.sklearn.PermutationFeatureImportance": {"model": vm_model, "dataset": vm_test_ds},
    "validmind.model_validation.sklearn.SHAPGlobalImportance": {"model": vm_model, "dataset": vm_test_ds},
    # Model diagnosis
    "validmind.model_validation.sklearn.WeakspotsDiagnosis": {"model": vm_model, "datasets": both},
    "validmind.model_validation.sklearn.OverfitDiagnosis": {"model": vm_model, "datasets": both},
    "validmind.model_validation.sklearn.RobustnessDiagnosis": {"model": vm_model, "datasets": both},
}

for test_id, inputs in tests.items():
    vm.tests.run_test(test_id, inputs=inputs).log()

In summary

In this notebook, you learned how to:

Next steps

You can look at the output produced by the ValidMind Library right in the notebook where you ran the code, as you would expect. But there is a better way — use the ValidMind Platform to work with your documentation.

Work with your documentation

  1. From the Inventory in the ValidMind Platform, go to the model you registered earlier. (Learn more: Working with the inventory)

  2. In the left sidebar that appears for your model, click Development under Documents.

What you see is the full draft of your documentation in a more easily consumable version. From here, you can make qualitative edits to documentation, view guidelines, collaborate with validators, and submit your documentation for approval when it's ready. (Learn more: Working with documentation)

Discover more learning resources

For a more in-depth introduction to using the ValidMind Library for development, check out our introductory development series and the accompanying interactive training:

  • ValidMind for development
  • Developer Fundamentals

We also offer many interactive notebooks to help you use the ValidMind Library to streamline your work:

  • Run tests & test suites
  • Use ValidMind Library features
  • Code samples by use case

Or, visit our documentation to learn more about ValidMind.

Upgrade ValidMind

After installing ValidMind, you’ll want to periodically make sure you are on the latest version to access any new features and other enhancements.

Retrieve the information for the currently installed version of ValidMind:

%pip show validmind

If the version returned is lower than the version indicated in our production open-source code, restart your notebook and run:

%pip install --upgrade validmind

You may need to restart your kernel after running the upgrade package for changes to be applied.


Copyright © 2023-2026 ValidMind Inc. All rights reserved.
Refer to LICENSE for details.
SPDX-License-Identifier: AGPL-3.0 AND ValidMind Commercial

Quickstart (OIDC device flow)
Install and initialize the library
  • ValidMind Logo
    ©
    Copyright 2026 ValidMind Inc.
    All Rights Reserved.
    Cookie preferences
    Legal
  • Get started
    • Development
    • Validation
    • Setup & admin
  • Guides
    • Access
    • Configuration
    • Integrations
    • Workflows
    • Inventory
    • Risk tiering
    • Documents & templates
    • Documentation
    • Validation
    • Reporting & auditing
    • Monitoring
    • Attestation
  • ValidMind Library
    • Quickstarts
    • Development tutorial
    • Validation tutorial
    • Run tests & test suites
    • Use library features
    • Code samples
    • Python API
    • Public REST API
  • Training
    • Learning paths
    • Courses
    • Videos
  • Support
    • Troubleshooting
    • FAQ
    • Get help
  • Edit this page
  • Report an issue
  • Community
    • GitHub
    • LinkedIn
    • Events
    • Blog