Skip to content

vector

Vector feature and type alias.

Classes:

Name Description
VectorFeature

Feature representing a vector composed of multiple sub-features.

MultivariateNumericalFeature

MultivariateNumericalFeature feature.

VectorFeature #

Feature representing a vector composed of multiple sub-features.

A vector feature encapsulates a collection of individual feature components (for example, numerical or categorical) grouped together under named channels. Each element of the vector corresponds to a distinct dimension identified by a channel name, and all elements share the same underlying feature type.

This structure is suitable for representing multidimensional entities such as coordinates, embeddings, or multi-attribute descriptors. For instance, a 3D point can be represented as a vector of three numerical features with channel names ("x", "y", "z"). Ideally, the channels of a vector feature should be statistically independent.

Parameters:

Name Type Description Default

items #

ItemType

The feature type associated with each channel. This defines the structure and semantics of the individual vector components.

required

channel_names #

tuple[str, ...]

Sequence of names identifying each channel in the vector. The order of the names must match the order of the corresponding feature components.

required

Methods:

Name Description
to_model

Convert to a VectorFeatureTypeInput instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
items ItemType
channel_names tuple[str, ...]
name Literal['VECTOR']

items: ItemType #

channel_names: tuple[str, ...] #

name: Literal['VECTOR'] = 'VECTOR' #

to_model() -> VectorFeatureTypeInput #

Convert to a VectorFeatureTypeInput instance.

Returns:

Type Description
VectorFeatureTypeInput

Model-level representation of the vector feature, including its channel names and the serialized form of its item feature type.

Source code in src/xpdeep/dataset/feature/feature_types/vector.py
def to_model(self) -> VectorFeatureTypeInput:
    """Convert to a `VectorFeatureTypeInput` instance.

    Returns
    -------
    VectorFeatureTypeInput
        Model-level representation of the vector feature, including its channel
        names and the serialized form of its item feature type.
    """
    return VectorFeatureTypeInput(
        name=self.name, items=self.items.to_model(), channel_names=list(self.channel_names)
    )

from_model(feature_type_input: VectorFeatureTypeInput) -> VectorFeature[ItemType] #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/vector.py
@staticmethod
def from_model(feature_type_input: VectorFeatureTypeInput) -> VectorFeature[ItemType]:
    """Instantiate from a json response."""
    return VectorFeature(
        items=cast(ItemType, feature_type_from_model(feature_type_input.items)),
        channel_names=tuple(feature_type_input.channel_names),
    )

MultivariateNumericalFeature #

MultivariateNumericalFeature feature.

It is an alias for a VectorFeature of Numerical items.

Parameters:

Name Type Description Default

channel_names #

List[str]

List of channel names used for visualization.

required
Notes
  • Conceptually equivalent to: VectorFeature(items=NumericalFeature, channel_names).

Attributes:

Name Type Description
items str

Methods:

Name Description
__attrs_post_init__

Update categories.

items: NumericalFeature = attrs.field(init=False) #

__attrs_post_init__() -> None #

Update categories.

Source code in src/xpdeep/dataset/feature/feature_types/vector.py
def __attrs_post_init__(self) -> None:
    """Update categories."""
    self.items = NumericalFeature()