torch_concepts.annotations.Concept

class Concept(name: str, index: int, cardinality: int, type: str, states: ~typing.List[str] | None, slice: slice, metadata: dict = <factory>)[source]

Read-only, per-concept view over a single column of an Annotations.

Groups one concept’s properties into a single named object so callers can write annotations.concept('color').cardinality instead of the index-dance int(annotations.cardinalities[annotations.get_index('color')]). It is a view: the values are read from the owning Annotations’ parallel lists at construction time (no duplicated storage), so the lists remain the canonical representation.

name

Concept label.

Type:

str

index

Concept-level index within the axis.

Type:

int

cardinality

Number of states (1 for binary/continuous scalars).

Type:

int

type

Concept type, one of 'binary' / 'categorical' / 'continuous'.

Type:

str

states

State labels for this concept.

Type:

Optional[List[str]]

slice

Column span of this concept in the flattened (logit) tensor.

Type:

slice

metadata

Raw per-concept metadata (escape hatch for extra keys).

Type:

dict

__init__(name: str, index: int, cardinality: int, type: str, states: ~typing.List[str] | None, slice: slice, metadata: dict = <factory>) None

Methods

__init__(name, index, cardinality, type, ...)

Attributes

is_binary

Whether this concept is a single binary value (cardinality 1).

is_categorical

Whether this concept is a multi-state (categorical) variable.

is_continuous

Whether this concept is continuous.

name

index

cardinality

type

states

slice

metadata