> ## 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.

# Class imbalance ratio

> Learn how to use the class imbalance ratio test

## Definition

The class imbalance ratio test allows you to set a threshold on the ratio between the number of rows from the most common class and the least common class.

## Taxonomy

* **Task types**: Tabular classification, text classification.
* **Availability**: development (Continuously evaluate your models and datasets as you iterate on their versions.).

## Why it matters

* Class imbalance can significantly impact the performance of predictive models.
* Measuring the class imbalance ratio helps select more appropriate [evaluation metrics](https://docs.openlayer.com/tests/performance/aggregate-metrics#available-metrics).
* Awareness of the extent of class imbalance guides the choice of model and data preprocessing techniques.
* While class imbalance is inherent to certain problems, it is important to continuously measure the class imbalance ratio to ensure that it does not go out of control.

## Test configuration examples

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

```json Development theme={null}
[
  {
    "name": "Class imbalance ratio at most 1.5",
    "description": "Asserts that the ratio between the majority and minority classes is at most 1.5 (i.e. the classes are not heavily imbalanced)",
    "type": "integrity",
    "subtype": "classImbalanceRatio",
    "thresholds": [
      {
        "insightName": "classImbalance",
        "measurement": "classImbalanceRatio",
        "operator": "<=",
        "value": 1.5
      }
    ],
    "subpopulationFilters": null,
    "mode": "development",
    "usesValidationDataset": true,
    "usesTrainingDataset": false,
    "usesMlModel": false,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

```json Monitoring theme={null}
[
  {
    "name": "Class imbalance ratio at most 1.5",
    "description": "Asserts that the ratio between the majority and minority classes is at most 1.5 (i.e. the classes are not heavily imbalanced)",
    "type": "integrity",
    "subtype": "classImbalanceRatio",
    "thresholds": [
      {
        "insightName": "classImbalance",
        "measurement": "classImbalanceRatio",
        "operator": "<=",
        "value": 1.5
      }
    ],
    "subpopulationFilters": null,
    "mode": "monitoring",
    "usesProductionData": true,
    "evaluationWindow": 3600,
    "delayWindow": 0,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

## Related

* Dealing with class imbalance, [part 1](https://www.openlayer.com/blog/post/dealing-with-class-imbalance-part-1) and [part 2](https://www.openlayer.com/blog/post/dealing-with-class-imbalance-part-2).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.