# classification

Python API: `depthai_nodes.message.creators.classification`

## Functions

### create_classification_message

```python
def create_classification_message(classes: list[str], scores: np.ndarray | list) -> dai.beta.Classifications:
```

Create a classification message sorted by descending score.

Parameters

 * `classes` (`list[str]`): Non-empty list of class names.
 * `scores` (`np.ndarray | list`): Floating-point probabilities corresponding to `classes`. Values must be between 0 and 1 and sum
   to 1 within an absolute tolerance of 0.1. A list or array that can be flattened to one probability per class is accepted.

Returns

 * `dai.beta.Classifications`: Native classification message containing sorted class names and scores. Classes with equal scores
   retain their input order.

Raises

 * `ValueError`: If classes or scores are empty, have unsupported types, differ in length, or scores are not valid floating-point
   probabilities.

### create_classification_sequence_message

```python
def create_classification_sequence_message(classes: list[str], scores: np.ndarray | list, ignored_indexes: list[int] | None = None, remove_duplicates: bool = False, concatenate_classes: bool = False) -> dai.beta.Classifications:
```

Create a classification sequence from per-position class probabilities.

Parameters

 * `classes` (`list[str]`): Class names, indexed by the columns of `scores`.
 * `scores` (`np.ndarray | list`): Array or nested list of shape `(sequence_length, n_classes)`. Each row must contain
   probabilities between 0 and 1 that sum to 1 within an absolute tolerance of 0.01.
 * `ignored_indexes` (`list[int] | None`): Class indexes to omit, such as a padding or background class.
 * `remove_duplicates` (`bool`): Remove adjacent repeated winning classes before filtering ignored indexes.
 * `concatenate_classes` (`bool`): If all selected class names have at most one character, join them into words separated by
   spaces and average the scores within each word.

Returns

 * `dai.beta.Classifications`: Native classification message with selected class names and scores in sequence order.

Raises

 * `ValueError`: If classes are not a list, scores have incompatible dimensions or invalid probabilities, or ignored indexes are
   not a list of valid integer class indexes.
