# set\_ground\_truth

The `leap_binder.set_ground_truth` binding function points to the [**Ground Truth Encoder**](/tensorleap-integration/writing-integration-code/ground-truth-encoder.md) and `name` for reference.

```python
code_loader.leap_binder.set_ground_truth(
    function=Callable[[int, PreprocessingResponse], np.ndarray]
    name=str
)
```

<table><thead><tr><th width="150">Args</th><th></th></tr></thead><tbody><tr><td><code>function</code></td><td><em>(Callable)</em> This parameter points to the <a href="/pages/qN1biq0MVRbxJTD89ase"><strong>Ground Truth Encoder</strong></a> function mentioned above.</td></tr><tr><td><code>name</code></td><td><em>(str)</em> with the given name of the <strong>input, e.</strong>g. image</td></tr></tbody></table>

### Examples

#### Basic Usage

```python
from code_loader import leap_binder
from code_loader.contract.datasetclasses import PreprocessResponse

...
def gt_encoder(idx: int, preprocessing: Union[PreprocessResponse, list]) -> np.ndarray:
    return preprocessing.data.iloc[idx]['ground_truth'].astype('float32')

leap_binder.set_ground_truth(
    function=gt_encoder,
    gt_name='classes'
)
```

Usage within the full script can be found at [**Integration Script**](/tensorleap-integration/writing-integration-code.md#dataset-script).

#### Guides

Full examples can be found at the **Dataset Integration** section of the following guides:

* [**MNIST Guide**](/guides/full-guides/mnist-guide.md)
* [**IMDB Guide**](/guides/full-guides/imdb-guide.md)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/leap_binder/set_ground_truth.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
