> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Great expectations

> Learn how to use Great Expectations with Openlayer

## Definition

[Great expectations](https://greatexpectations.io/) (GX) is an open-source Python library that allows you to define expectations about your data.
GX is integrated into Openlayer, allowing you to use any GX expectations as Openlayer tests. To check
all the expectations supported, check out the [GX expectations gallery](https://greatexpectations.io/expectations).

## Taxonomy

* **Task types**: LLM, tabular classification, tabular regression, text classification.
* **Availability**: <Tooltip tip="Continuously evaluate your models and datasets as you iterate on their versions.">development</Tooltip>
  and <Tooltip tip="Monitor a model in production, measure its health, check for drifts and set up alerts.">monitoring</Tooltip>.

## Why it matters

* Data is the substrate on top of which models are built. Validating that the data conforms to expectations is a key step in the model development and monitoring processes.
* GX is a powerful tool that allows you to easily set up a myriad of expectations on your data.

## Guide

To create a GX test, click on "Create test" for the "Great expectations" test.

<img width="700" style={{ borderRadius: "0.5rem" }} src="https://mintcdn.com/openlayer-44/xUBIrdsfSKEziWQ7/images/tests/integrity/gx_test.png?fit=max&auto=format&n=xUBIrdsfSKEziWQ7&q=85&s=cadfcb66c3b795cbcfeb8c25758216a9" alt="GX test" data-path="images/tests/integrity/gx_test.png" />

Then, once the modal is open, select the expectation you are interested in from the dropdown
menu next to "Parameters." For example, let's select the `expect_column_mean_to_be_between`.

<img width="700" style={{ borderRadius: "0.5rem" }} src="https://mintcdn.com/openlayer-44/xUBIrdsfSKEziWQ7/images/tests/integrity/gx_selection.png?fit=max&auto=format&n=xUBIrdsfSKEziWQ7&q=85&s=64185f3446bf33d4c0e24d65066f9b77" alt="GX selection" data-path="images/tests/integrity/gx_selection.png" />

Once you have selected the expectation, you need to provide the arguments needed to run it. You can click
the link next to "Parameters" to see the documentation for the expectation you selected. In this case, the
expectation requires a `column`, with the name of the column, a `min_value`, and a `max_value`. You can provide
these arguments by clicking on "Add kwarg".

<img width="700" style={{ borderRadius: "0.5rem" }} src="https://mintcdn.com/openlayer-44/xUBIrdsfSKEziWQ7/images/tests/integrity/gx_config.png?fit=max&auto=format&n=xUBIrdsfSKEziWQ7&q=85&s=db899617b2d0ace50aec8f257074ed66" alt="GX configuration" data-path="images/tests/integrity/gx_config.png" />

The "Threshold" should be kept as "Success is True," as the expectation will return `True` if the expectation is met
(in this case, the column mean is between the `min_value` and the `max_value`).

Once you have added all the arguments, you can click on "Create test" to create the test.

## Test configuration examples

If you are writing a `tests.json`, here are a few valid configurations for the character length test:

<CodeGroup>
  ```json Development theme={null}
  [
    {
      "name": "Expect outputs to be within 0 and 10 - GX test",
      "description": "Use the `expect_column_mean_to_be_between` from GX to check min and max values for column `output`",
      "type": "integrity",
      "subtype": "greatExpectations",
      "thresholds": [
        {
          "insightName": "greatExpectations",
          "insightParameters": [
            {
              "name": "expectation_name",
              "value": "expect_column_mean_to_be_between"
            }, // Define the expectation from GX
            {
              "name": "expectation_kwargs",
              "value": { "column": "output", "min_value": 0, "max_value": 10 }
            }
          ], // Defines the expectation kwargs
          "measurement": "success", // If the expectation is met, `success` is `true`
          "operator": "is",
          "value": true
        }
      ],
      "subpopulationFilters": null,
      "mode": "development",
      "usesValidationDataset": true, // Apply test to the validation set
      "usesTrainingDataset": false,
      "usesMlModel": false,
      "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689" // Some unique id
    }
  ]
  ```

  ```json Monitoring theme={null}
  [
    {
      "name": "Expect outputs to be within 0 and 10 - GX test",
      "description": "Use the `expect_column_mean_to_be_between` from GX to check min and max values for column `output`",
      "type": "integrity",
      "subtype": "greatExpectations",
      "thresholds": [
        {
          "insightName": "greatExpectations",
          "insightParameters": [
            {
              "name": "expectation_name",
              "value": "expect_column_mean_to_be_between"
            }, // Define the expectation from GX
            {
              "name": "expectation_kwargs",
              "value": { "column": "output", "min_value": 0, "max_value": 10 }
            }
          ], // Defines the expectation kwargs
          "measurement": "success", // If the expectation is met, `success` is `true`
          "operator": "is",
          "value": true
        }
      ],
      "subpopulationFilters": null,
      "mode": "monitoring",
      "usesProductionData": true,
      "evaluationWindow": 3600, // 1 hour
      "delayWindow": 0,
      "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689" // Some unique id
    }
  ]
  ```
</CodeGroup>

## Related

* [GX expectations gallery](https://greatexpectations.io/expectations).
