LogoLogo
AboutBlogLaunch app ↗
v0.23.x
v0.23.x
  • Get Started
  • Overview
  • Getting Access to Distributional
  • Install the Python SDK
  • Quickstart
  • Learning about Distributional
    • Distributional Concepts
    • Why We Test Data Distributions
    • The Flow of Data
  • Using Distributional
    • Projects
    • Runs
      • Reporting Runs
      • Setting a Baseline Run
    • Metrics
    • Tests
      • Creating Tests
        • Using Filters in Tests
        • Available Statistics and Assertions
      • Running Tests
      • Reviewing Tests
        • What Is a Similarity Index?
    • Notifications
    • Access Controls
      • Organization and Namespaces
      • Users and Permissions
      • Tokens
  • Platform
    • Sandbox
    • Self-hosted
      • Architecture
      • Deployment
        • Helm Chart
        • Terraform Module
      • Networking
      • OIDC Authentication
      • Data Security
  • Reference
    • Query Language
      • Functions
    • Python SDK
      • dbnl
      • dbnl.util
      • dbnl.experimental
      • Classes
      • Eval Module
        • Quick Start
        • dbnl.eval
        • dbnl.eval.metrics
        • Application Metric Sets
        • How-To / FAQ
        • LLM-as-judge and Embedding Metrics
        • RAG / Question Answer Example
      • Classes
  • CLI
  • Versions
    • Release Notes
Powered by GitBook

© 2025 Distributional, Inc. All Rights Reserved.

On this page

Was this helpful?

Export as PDF
  1. Using Distributional
  2. Tests
  3. Creating Tests

Using Filters in Tests

PreviousCreating TestsNextAvailable Statistics and Assertions

Last updated 1 month ago

Was this helpful?

Filters can be used to specify a sub-selection of rows in Runs you would like to be tested.

For example, you might want to create a test that asserts that the absolute difference of means of the correct churn predictions is <= 0.2 between Baseline and Experiment Runs, only for rows where the loc column is NY.

Apply a Filter to a Test

Navigate to the and create the test with the filter specified on the baseline and experiment run.

Filter for the baseline Run:

equal_to({BASELINE}.loc, 'NY')

Filter for the experiment Run:

equal_to({EXPERIMENT}.loc, 'NY')
import dbnl
dbnl.login()

proj = dbnl.get_or_create_project(name="My Project")

dbnl.experimental.create_test(
    test_spec_dict={
        "project_id": proj.id,
        "name": "abs diff of mean of correct churn preds of NY users is within 0.2",
        "statistic_name": "abs_diff_mean",
        "statistic_params": {},
        "assertion": {
            "name": "less_than_or_equal_to",
            "params": {
                "other": 0.2
            },
        },
        "statistic_inputs": [
            {
                "select_query_template": {
                    "select": "{BASELINE}.pred_correct",
                    "filter": "equal_to({BASELINE}.loc, 'NY')"
                }
            },
            {
                "select_query_template": {
                    "select": "{EXPERIMENT}.pred_correct",
                    "filter": "equal_to({EXPERIMENT}.loc, 'NY')"
                }
            },
        ],
    }
)

Once you've used one of the methods above, you can now see the new test in the Test Configuration tab of your Project.

When a Test Session is created, this test will use the defined filters to sub-select for the rows that have the loc column equal to NY.

You can create a test with filters in the SDK via the function:

create_test
Create Test page