> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encord.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Objects.classification

## OntologyClassificationLevel Objects

```python theme={"dark"}
class OntologyClassificationLevel(StringEnum)
```

Enumeration representing the hierarchical level of a classification
within an ontology.

**Attributes**:

* `GLOBAL` *OntologyClassificationLevel* - Indicates a global, whole-image
  classification that applies to the entire data unit rather than
  to a specific object or region.

## Classification Objects

```python theme={"dark"}
@dataclass
class Classification(OntologyElement)
```

Represents a whole-image classification as part of an Ontology structure.

This class encapsulates an image-level classification that describes the
entire data unit rather than individual labeled objects. Each classification
wraps a single `Attribute` (or multiple, if applicable) that defines metadata
or semantic context for the image, such as scene type, lighting condition,
or general content category.

**Attributes**:

* `uid` *int* - Deprecated. Please use `feature_node_hash` instead.
* `feature_node_hash` *str* - Unique hash value identifying the feature node
  in the ontology tree corresponding to this classification.
* `attributes` *List\[Attribute]* - List of `Attribute` instances that define
  the semantic meaning or properties associated with the classification.
* `_level` *OntologyClassificationLevel | None* - The hierarchical level of
  this classification (for example: `GLOBAL`). Optional: defaults to None.

**Example**:

```
    >>> classification = Classification(
    ...     uid=1,
    ...     feature_node_hash="abc123",
    ...     attributes=[Attribute(name="Scene Type", value="Indoor")],
    ...     level=OntologyClassificationLevel.GLOBAL,
    ... )
```

#### title

```python theme={"dark"}
@property
def title() -> str
```

Returns the title of the classification, which is the name of the first attribute.

**Returns**:

* `str` - The title of the classification.

#### level

```python theme={"dark"}
@property
def level() -> OntologyClassificationLevel | None
```

Get the level of the classification.

**Returns**:

OntologyClassificationLevel | None: The level of the classification.

#### children

```python theme={"dark"}
@property
def children() -> Sequence[OntologyElement]
```

Returns the attributes of the classification as children elements.

**Returns**:

* `Sequence[OntologyElement]` - The attributes of the classification.

#### is\_global

```python theme={"dark"}
@property
def is_global() -> bool
```

Check if the classification is global.

**Returns**:

* `bool` - True if the classification level is global, False otherwise.

#### create\_instance

```python theme={"dark"}
def create_instance(range_only: bool = False) -> ClassificationInstance
```

Create a ClassificationInstance to be used with a label row.

**Returns**:

* `ClassificationInstance` - An instance of ClassificationInstance.

#### from\_dict

```python theme={"dark"}
@classmethod
def from_dict(cls, d: dict) -> Classification
```

Create a Classification instance from a dictionary.

**Arguments**:

* `d` *dict* - A dictionary containing classification information.

**Returns**:

* `Classification` - An instance of Classification.

#### to\_dict

```python theme={"dark"}
def to_dict() -> Dict[str, Any]
```

Convert the Classification instance to a dictionary.

**Returns**:

Dict\[str, Any]: A dictionary representation of the classification.

**Raises**:

* `ValueError` - If the classification does not have any attributes.

#### add\_attribute

```python theme={"dark"}
def add_attribute(cls: Type[AttributeType],
                  name: str,
                  local_uid: Optional[int] = None,
                  feature_node_hash: Optional[str] = None,
                  required: bool = False) -> AttributeType
```

Adds an attribute to the classification.

**Arguments**:

* `cls` *Type\[AttributeType]* - The attribute type, one of `RadioAttribute`, `ChecklistAttribute`, `TextAttribute`.
* `name` *str* - The user-visible name of the attribute.
* `local_uid` *Optional\[int]* - Integer identifier of the attribute. Normally auto-generated; omit this unless
  the aim is to create an exact clone of an existing ontology.
* `feature_node_hash` *Optional\[str]* - Global identifier of the attribute. Normally auto-generated; omit this
  unless the aim is to create an exact clone of an existing ontology.
* `required` *bool* - Whether the label editor would mark this attribute as 'required'.

**Returns**:

* `AttributeType` - The created attribute that can be further specified with Options, where appropriate.

**Raises**:

* `ValueError` - If the classification already has an attribute assigned.
