> For the complete documentation index, see [llms.txt](https://docs.tensorleap.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/datasetclasses/leapanalysisconfiguration.md).

# LeapAnalysisConfiguration

code\_loader.contract.responsedataclasses.LeapAnalysisConfiguration

`LeapAnalysisConfiguration` sets optional analysis behaviors for a project. Set it on the `leap_binder` object in your integration script, at module level (outside any decorated function).

```python
@dataclass
class LeapAnalysisConfiguration:
    domain_gap_metadata: Optional[List[str]] = None
    feature_flags: Optional[List[str]] = None
    deterministic_results: Optional[bool] = None
    ignore_latent_spaces: Optional[List[str]] = None
    use_additional_set_as_unlabeled_candidate: Optional[bool] = None
```

| Field                                       |                                                                                                                                                                                                                                                                                                                                                                    |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `domain_gap_metadata`                       | *(Optional\[List\[str]])* Names of metadata fields to use for domain gap analysis. Each name must match a registered [`@tensorleap_metadata`](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_metadata.md) field.                                                                                                   |
| `feature_flags`                             | *(Optional\[List\[str]])* Engine feature flags to turn on. See [Feature Flags](#feature-flags).                                                                                                                                                                                                                                                                    |
| `deterministic_results`                     | *(Optional\[bool])* When `True`, analysis results are the same on every run. This uses more memory and takes longer. Defaults to `False`.                                                                                                                                                                                                                          |
| `ignore_latent_spaces`                      | *(Optional\[List\[str]])* Latent spaces the engine should not extract. See [Ignoring latent spaces](#ignoring-latent-spaces).                                                                                                                                                                                                                                      |
| `use_additional_set_as_unlabeled_candidate` | *(Optional\[bool])* Whether samples in the **additional** set (e.g. [simulated samples](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_simulation.md)) are offered as candidates in labeling prioritization, unlabeled-data analysis and aggressor fixing. `None` (the default) means yes; `False` keeps them out. |

## Basic Usage

```python
from code_loader import leap_binder
from code_loader.contract.responsedataclasses import LeapAnalysisConfiguration

leap_binder.leap_analysis_configuration = LeapAnalysisConfiguration(
    deterministic_results=True,
    feature_flags=['FEATURE_FLAG_MISLABELED_ON_ALL_CATEGORICAL_METADATA'],
    ignore_latent_spaces=['foreground'],
)
```

## Ignoring latent spaces

Each name in `ignore_latent_spaces` must be one of:

| Name                                                                                                                                                | Latent space it turns off                                              |
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| `foreground`                                                                                                                                        | The built-in max-pooled latent space                                   |
| The `name` of an [input encoder](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_input_encoder.md)   | The latent space taken from the model's early layers for that input    |
| The `name` of a [prediction type](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/datasetclasses/predictiontypehandler.md) | The latent space taken from the model's last layers before that output |

`balanced` (the built-in fallback latent space) cannot be ignored. Any other name fails the [integration test](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_integration_test.md) check with the list of valid names.

## Feature Flags

Feature flags are passed as strings in the `feature_flags` list. All of them are off by default. The following flags are supported:

| Flag                                                  |                                                                                                  |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `FEATURE_FLAG_MISLABELED_ON_ALL_CATEGORICAL_METADATA` | Run mislabeled-sample detection on every categorical metadata field, not only the primary label. |
| `FEATURE_FLAG_USE_PCA_IN_PRUNING`                     | Use a PCA-unified latent space when computing dataset pruning (similarity-based deduplication).  |
| `FEATURE_FLAG_TRAINING_RELEVANCE_SCORES`              | Compute relevance scores using the training set.                                                 |
| `FEATURE_FLAG_TRAINING_DENSITY_WEIGHTS`               | Compute density weights using the training set.                                                  |
| `FEATURE_FLAG_COMPUTE_PREDICTED_LOSS`                 | Compute a predicted loss score per sample.                                                       |

{% hint style="warning" %}
Earlier versions of this page spelled the pruning flag `FEATURE_FLAG_USE_PCA_IN_PRUNNING` (double N). That spelling is not recognized by the engine and has no effect.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/datasetclasses/leapanalysisconfiguration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
