> 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/leap_binder/add_prediction.md).

# add\_prediction

The purpose of the `leap_binder.add_prediction` function is to describe the prediction(s) tensors for visualization and analysis purposes. This function adds a prediction type, which later can be assigned to the model graph prediction node(s).

```python
code_loader.leap_binder.add_prediction(
    name=str,
    labels=List[str]
    channel_dim: int = -1
)
```

<table><thead><tr><th width="158.46928201888204">Args</th><th></th></tr></thead><tbody><tr><td><code>name</code></td><td><em>(str)</em> with the given name of the <strong>input,</strong> e.g. image</td></tr><tr><td><code>labels</code></td><td><em>(List[str])</em> an array containing the labels associated with this <strong>prediction</strong></td></tr><tr><td><code>channel_dim</code></td><td>(defaults to -1). The dimension in which the channels exists in the prediction. channel_dim should be set to 1 for channel first predictions (i.e. - C,H,W).</td></tr></tbody></table>

### Examples

#### Basic Usage

```python
...

LABELS = ['0','1','2','3','4','5','6','7','8','9']
leap_binder.add_prediction(
    name='predicted_digit',
    labels=LABELS
)
```

Full script usage 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
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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
