# PredictionTypeHandler

The purpose of `PredictionTypeHandler` is to describe the prediction(s) tensors for visualization and analysis purposes.

```python
@dataclass
class PredictionTypeHandler:
    name: str
    labels: List[str]
    channel_dim: int = -1
```

For more on `PredictionTypeHandler`:

<table><thead><tr><th width="158.46928201888204">Args</th><th></th></tr></thead><tbody><tr><td><code>name</code></td><td><em>(str)</em> The given name of the <strong>output,</strong> e.g. image/logits/entity</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

#### MNIST example

One output, which we name `classes` that has 10 channels, each a logit for the classification of a digit

```python
from code_loader.contract.datasetclasses import PredictionTypeHandler
prediction_type1 = PredictionTypeHandler(name='classes', labels=[str(i) for i in range(10)])
```

#### YOLO example

Four outputs:

* a conctatenated prediction with #channels = 4 + #classes
* Three scales, with #channels of 20,40,80

```python
prediction_type1 = PredictionTypeHandler(name='object detection', labels=["x", "y", "w", "h"] + [cl for cl in all_clss.values()], channel_dim=1)
prediction_type2 = PredictionTypeHandler(name='concatenate_20', labels=[str(i) for i in range(20)], channel_dim=-1)
prediction_type3 = PredictionTypeHandler(name='concatenate_40', labels=[str(i) for i in range(40)], channel_dim=-1)
prediction_type4 = PredictionTypeHandler(name='concatenate_80', labels=[str(i) for i in range(80)], channel_dim=-1)
```


---

# 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/datasetclasses/predictiontypehandler.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.
