Skip to content

feature_types

Access all feature types.

Modules:

Name Description
abstract_type

Abstract feature type interface.

bbox

Bbox related features.

categorical

Categorical and ordinal features.

feature_from_model

Utility function to infer feature type from an unknow json response.

histogram

Histogram feature types.

image

Image feature types.

list

List feature types.

numerical

Numerical feature types.

time_series

Time series feature types.

vector

Vector feature and type alias.

Type Aliases:

Name Description
FeatureTypeUnion

Classes:

Name Description
FeatureType

Abstract class representing a feature type.

BboxFeature

Feature representing a bounding box.

BoundingBoxesFeature

Feature representing a list of bounding boxes within a single image.

CategoricalFeature

Categorical feature.

OrdinalFeature

Feature representing an ordered categorical variable.

HistogramFeature

Feature representing a histogram-based data distribution.

ImageFeature

Feature representing an image input or output.

ListFeature

Feature representing a collection of sub-features without temporal ordering.

NumericalFeature

Numerical feature.

MultivariateTimeSeriesFeature

Feature representing a multivariate time series.

TimeSeriesFeature

Feature representing a temporal sequence of sub-features.

UnivariateTimeSeriesFeature

Alias type representing a univariate time series.

MultivariateNumericalFeature

MultivariateNumericalFeature feature.

VectorFeature

Feature representing a vector composed of multiple sub-features.

__all__ = ['BboxFeature', 'BboxFeature', 'BoundingBoxesFeature', 'CategoricalFeature', 'FeatureType', 'FeatureTypeUnion', 'HistogramFeature', 'ImageFeature', 'ListFeature', 'MultivariateNumericalFeature', 'MultivariateNumericalFeature', 'MultivariateTimeSeriesFeature', 'NumericalFeature', 'OrdinalFeature', 'TimeSeriesFeature', 'UnivariateTimeSeriesFeature', 'VectorFeature'] #

FeatureTypeUnion = BboxFeature | CategoricalFeature | OrdinalFeature | HistogramFeature | ImageFeature | ListFeature[FeatureType] | NumericalFeature | TimeSeriesFeature[FeatureType] | VectorFeature[FeatureType] #

FeatureType #

Abstract class representing a feature type.

Methods:

Name Description
to_model

Convert to an Api client feature type.

stable_hash

Return the feature type hash based on its database model.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
name str

name: str = '' #

to_model() -> ApiClientFeatureType #

Convert to an Api client feature type.

Source code in src/xpdeep/dataset/feature/feature_types/abstract_type.py
def to_model(self) -> ApiClientFeatureType:
    """Convert to an Api client feature type."""
    raise NotImplementedError

stable_hash() -> str #

Return the feature type hash based on its database model.

Source code in src/xpdeep/dataset/feature/feature_types/abstract_type.py
def stable_hash(self) -> str:
    """Return the feature type hash based on its database model."""
    return str(sha256(f"{self.to_model().to_dict()}".encode()).hexdigest())

from_model(feature_type_input: Any) -> FeatureType #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/abstract_type.py
@staticmethod
def from_model(feature_type_input: Any) -> FeatureType:  # type:ignore[explicit-any]  # noqa:ANN401
    """Instantiate from a json response."""
    raise NotImplementedError

BboxFeature #

Feature representing a bounding box.

This feature represents a single bbox in YOLO format for object detection tasks described by positional coordinates, class category, and detection score.

Bounding boxes follow the YOLO format, where each box is parameterized by: - center_x and center_y: normalized coordinates of the box center within the image. - width and height: normalized dimensions of the box. - class: category index or label of the detected object. - score: confidence score associated with the detection.

Parameters:

Name Type Description Default

categories #

list[int] or list[str]

List of category identifiers or labels corresponding to the possible object classes.

required
Notes
  • This feature is mostly meant to be used through BoundingBoxesFeature

Methods:

Name Description
to_model

Convert to a ListFeatureTypeInput instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
categories list[int] | list[str]
name Literal['BBOX']

categories: list[int] | list[str] #

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

to_model() -> BBoxFeatureType #

Convert to a ListFeatureTypeInput instance.

Returns:

Type Description
ListFeatureTypeInput

Model-level representation of the bounding boxes feature, including the serialized box structure and category information.

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

    Returns
    -------
    ListFeatureTypeInput
        Model-level representation of the bounding boxes feature, including
        the serialized box structure and category information.
    """
    return BBoxFeatureType(
        name=self.name,
        size=[0, 0],
        categories=self.categories,
        channel_names=["class", "center_x", "center_y", "width", "height", "score"],
    )

from_model(feature_type_input: BBoxFeatureType) -> BboxFeature #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/bbox.py
@staticmethod
def from_model(feature_type_input: BBoxFeatureType) -> BboxFeature:
    """Instantiate from a json response."""
    return BboxFeature(categories=feature_type_input.categories)

BoundingBoxesFeature #

Feature representing a list of bounding boxes within a single image.

This feature encodes object detections as a collection of bounding boxes, each described by positional coordinates, class category, and detection score. It provides a structured way to represent outputs from object detection models or annotated datasets.

Bounding boxes follow the YOLO format, where each box is parameterized by: - center_x and center_y: normalized coordinates of the box center within the image. - width and height: normalized dimensions of the box. - class: category index or label of the detected object. - score: confidence score associated with the detection.

Parameters:

Name Type Description Default

categories #

list[int] or list[str]

List of category identifiers or labels corresponding to the possible object classes.

required
Notes
  • Bounding boxes are represented as a list of homogeneous sub-features.
  • This feature is typically used to represent detections within a single image or frame.
  • Current limitation: Xpdeep does not yet support variable numbers of detections per instance. Please pad bounding box lists to a uniform length before using this feature.

Attributes:

Name Type Description
items str

Methods:

Name Description
__attrs_post_init__

Update categories.

categories: list[int] | list[str] #

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

__attrs_post_init__() -> None #

Update categories.

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

CategoricalFeature #

Categorical feature.

It represents data (bool, int or str only) that can be divided into distinct groups or categories.

It may be nominal or ordinal. For instance, "Education level" or "gender" could be set as categorical features.

Parameters:

Name Type Description Default

categories #

list[str] | list[int] | None
  1. When building an AnalyzedSchema: If the preprocessor is one of label_encoder, onehot_encoder, then categories are automatically inferred from the preprocessor when fitted, and you should not provide any categories. Else, categories must be provided.
  2. When building a FittedSchema, categories must be provided. The categories' order must match the preprocessor's processing order.
  3. When using the dataset analyze and fit methods, no categories should be provided.
None

Methods:

Name Description
to_model

Convert to CategoricalFeatureType instance.

parse_categories_to_list

Convert categories to an empty list if they are None.

__attrs_post_init__

Return a fake category to be overwritten by the fitted preprocessor inferred categories.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
name Literal['CATEGORICAL']
categories list[str] | list[int] | None

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

categories: list[str] | list[int] | None = None #

to_model() -> CategoricalFeatureType #

Convert to CategoricalFeatureType instance.

Source code in src/xpdeep/dataset/feature/feature_types/categorical.py
def to_model(self) -> CategoricalFeatureType:
    """Convert to CategoricalFeatureType instance."""
    return CategoricalFeatureType(
        name=self.name,
        categories=self.parse_categories_to_list(self.categories),
    )

parse_categories_to_list(categories: list[str] | list[int] | None) -> list[str] | list[int] #

Convert categories to an empty list if they are None.

Source code in src/xpdeep/dataset/feature/feature_types/categorical.py
@staticmethod
def parse_categories_to_list(categories: list[str] | list[int] | None) -> list[str] | list[int]:
    """Convert categories to an empty list if they are None."""
    return [] if categories is None or len(categories) == 0 else categories

__attrs_post_init__() -> None #

Return a fake category to be overwritten by the fitted preprocessor inferred categories.

Source code in src/xpdeep/dataset/feature/feature_types/categorical.py
def __attrs_post_init__(self) -> None:
    """Return a fake category to be overwritten by the fitted preprocessor inferred categories."""
    if self.categories is None:
        self.categories = ["fake_categories"]

from_model(feature_type_input: CategoricalFeatureType) -> CategoricalFeature #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/categorical.py
@staticmethod
def from_model(feature_type_input: CategoricalFeatureType) -> CategoricalFeature:
    """Instantiate from a json response."""
    return CategoricalFeature(
        categories=feature_type_input.categories if len(feature_type_input.categories) > 0 else None
    )

OrdinalFeature #

Feature representing an ordered categorical variable.

An ordinal feature encodes categories that have a defined order or ranking, such as "low", "medium", "high". In contrast to nominal (unordered) categories, ordinal features include a notion of distance between categories, quantified by an associated cost matrix.

Parameters:

Name Type Description Default

categories #

list[str] or list[int]

Ordered list of category labels. The order in the list must correspond to the order used in the cost matrix.

required

cost_matrix #

ndarray

Two-dimensional matrix specifying the pairwise cost or distance between categories. The entry at position (i, j) represents the cost of moving from category i to category j.

required

Methods:

Name Description
to_model

Convert to an OrdinalFeatureType instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
categories list[str] | list[int]
cost_matrix ndarray
name Literal['ORDINAL']

categories: list[str] | list[int] #

cost_matrix: np.ndarray #

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

to_model() -> OrdinalFeatureType #

Convert to an OrdinalFeatureType instance.

Returns:

Type Description
OrdinalFeatureType

A feature model representation including the category list and cost matrix.

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

    Returns
    -------
    OrdinalFeatureType
        A feature model representation including the category list and cost matrix.
    """
    if len(self.categories) != self.cost_matrix.shape[0] or len(self.categories) != self.cost_matrix.shape[1]:
        msg = (
            "Invalid cost matrix dimension, expect the cost matrix to be a squared matrix"
            "And the dimension should be equal to the number of categories. "
            "Gt { len(self.categories)} categories and a matrix of shape {self.cost_matrix.shape}"
        )
        raise ValueError(msg)

    return OrdinalFeatureType(name=self.name, categories=self.categories, cost_matrix=self.cost_matrix.tolist())

from_model(feature_type_input: OrdinalFeatureType) -> OrdinalFeature #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/categorical.py
@staticmethod
def from_model(feature_type_input: OrdinalFeatureType) -> OrdinalFeature:
    """Instantiate from a json response."""
    return OrdinalFeature(
        categories=feature_type_input.categories, cost_matrix=np.array(feature_type_input.cost_matrix)
    )

HistogramFeature #

Feature representing a histogram-based data distribution.

This feature encodes the statistical distribution of values through histogram bins. It can be used to summarize numerical data, such as activation distributions, probability outputs, or pixel intensity histograms in an image.

Parameters:

Name Type Description Default

bin_names #

tuple[str, ...]

Names of the histogram bins. Each entry typically corresponds to a range or label describing the data segment represented by the bin.

required

bins #

list[float] or None

Numerical values representing the histogram counts or frequencies for each bin.

None

Methods:

Name Description
to_model

Convert to a HistogramFeatureType instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
bin_names tuple[str, ...]
bins list[float] | None
name Literal['HISTOGRAM']

bin_names: tuple[str, ...] #

bins: list[float] | None = None #

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

to_model() -> HistogramFeatureType #

Convert to a HistogramFeatureType instance.

Returns:

Type Description
HistogramFeatureType

A feature model representation including the bin names and bin values.

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

    Returns
    -------
    HistogramFeatureType
        A feature model representation including the bin names and bin values.
    """
    return HistogramFeatureType(name=self.name, channel_names=list(self.bin_names), bins=self.bins)

from_model(feature_type_input: HistogramFeatureType) -> HistogramFeature #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/histogram.py
@staticmethod
def from_model(feature_type_input: HistogramFeatureType) -> HistogramFeature:
    """Instantiate from a json response."""
    bin_names = feature_type_input.channel_names
    bins = feature_type_input.bins if not isinstance(feature_type_input.bins, Unset) else None

    return HistogramFeature(bin_names=tuple(bin_names), bins=bins)

ImageFeature #

Feature representing an image input or output.

This feature models image data as a multidimensional numerical tensor with pixel intensities arranged in channel-last format. It is typically used to represent visual inputs such as photographs, rendered scenes, or segmentation masks.

The expected tensor shape is (batch_size, height, width, num_channels), where: - height and width are the spatial dimensions of the image, - num_channels corresponds to the color or modality channels (for example, 1 for grayscale, 3 for RGB, 4 for RGBA, or more for multispectral images).

Notes
  • Image data must use the channel-last layout (H x W x C).
  • The numerical type and normalization of pixel values depend on the associated preprocessing pipeline (for example, values in [0, 1] or [0, 255]).
  • Current limitation: Xpdeep assumes fixed image dimensions across all instances of the dataset; resizing or cropping should be handled during preprocessing.

Methods:

Name Description
to_model

Convert to an ImageFeatureType instance.

from_model

Image from model.

Attributes:

Name Type Description
name Literal['IMAGE']

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

to_model() -> ImageFeatureType #

Convert to an ImageFeatureType instance.

Returns:

Type Description
ImageFeatureType

Model-level representation of the image feature, including its static structural definition.

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

    Returns
    -------
    ImageFeatureType
        Model-level representation of the image feature, including its static
        structural definition.
    """
    return ImageFeatureType(name=self.name)

from_model(feature_type_input: ImageFeatureType) -> ImageFeature #

Image from model.

Source code in src/xpdeep/dataset/feature/feature_types/image.py
@staticmethod
def from_model(feature_type_input: ImageFeatureType) -> ImageFeature:  # noqa:ARG004
    """Image from model."""
    return ImageFeature()

ListFeature #

Feature representing a collection of sub-features without temporal ordering.

A list feature encodes a variable-length sequence of feature instances that share the same feature type, defined by items. In contrast to TimeSeriesFeature, a list does not imply any temporal or sequential relationship between elements; it simply groups multiple instances of the same feature together.

This structure is suitable for representing sets or collections of homogeneous entities, such as a list of detected objects, word embeddings, or samples within a batch.

Parameters:

Name Type Description Default

items #

ItemType

Feature type of each element in the list. All elements must share the same underlying feature definition.

required
Notes
  • The order of elements in the list is not semantically meaningful.
  • This feature type is close to a TimeSeriesFeature without temporal context. It can be used for unordered sequences or collections of arbitrary length.
  • Current limitation: Xpdeep does not yet support variable-length lists. Please pad all lists to a uniform length before using this feature.

Methods:

Name Description
to_model

Convert to a ListFeatureTypeInput instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
items ItemType
name Literal['LIST']

items: ItemType #

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

to_model() -> ListFeatureTypeInput #

Convert to a ListFeatureTypeInput instance.

Returns:

Type Description
ListFeatureTypeInput

Model-level representation of the list feature, including its serialized item feature type.

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

    Returns
    -------
    ListFeatureTypeInput
        Model-level representation of the list feature, including its serialized
        item feature type.
    """
    return ListFeatureTypeInput(
        name=self.name,
        items=self.items.to_model(),
    )

from_model(feature_type_input: ListFeatureTypeInput) -> ListFeature[ItemType] #

Instantiate from a json response.

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

NumericalFeature #

Numerical feature.

It represents quantifiable values that can be measured and ordered. Its values may be continuous (e.g., real numbers) or discrete (e.g., integers). For instance, "age" or "price" could be set as numerical features.

Methods:

Name Description
to_model

Convert to NumericalFeatureType instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
name Literal['NUMERICAL']

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

to_model() -> NumericalFeatureType #

Convert to NumericalFeatureType instance.

Source code in src/xpdeep/dataset/feature/feature_types/numerical.py
def to_model(self) -> NumericalFeatureType:
    """Convert to NumericalFeatureType instance."""
    return NumericalFeatureType(name=self.name)

from_model(feature_type_input: NumericalFeatureType) -> NumericalFeature #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/numerical.py
@staticmethod
def from_model(feature_type_input: NumericalFeatureType) -> NumericalFeature:  # noqa:ARG004
    """Instantiate from a json response."""
    return NumericalFeature()

MultivariateTimeSeriesFeature #

Feature representing a multivariate time series.

This feature models a temporal sequence of synchronized numerical channels. Each time step is represented as a vector of numerical values, one per channel. It is equivalent to a TimeSeriesFeature of a VectorFeature composed of numerical sub-features.

Parameters:

Name Type Description Default

asynchronous #

str
False

channel #

str
None

channel_names #

str
required

Attributes:

Name Type Description
items str

Methods:

Name Description
__attrs_post_init__

Update categories.

channel_names: tuple[str, ...] #

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

__attrs_post_init__() -> None #

Update categories.

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

TimeSeriesFeature #

Feature representing a temporal sequence of sub-features.

A time series feature encodes a sequence of feature instances observed over time. Each element in the series shares the same feature type and structure, defined by the items attribute. This representation is suitable for modeling dynamic signals, evolving states, or sequential sensor measurements.

The asynchronous flag indicates cross-instance temporal alignment at the dataset level: when True, different samples in the dataset need not be aligned in time (for example, sequences may have different start times,or sampling schedules). When False, sequences across instances are expected to be aligned (for example, same timestamps or a shared index), enabling direct time-wise comparisons.

Parameters:

Name Type Description Default

items #

ItemType

The feature type representing each element in the temporal sequence. This defines the internal structure and semantics of the time-dependent data.

required

asynchronous #

bool

Indicate whether sequences across dataset instances are temporally aligned. If True, instances may be misaligned (different start times, lengths, or grids). If False, instances are aligned to a common temporal reference.

False

channel #

tuple[str, str] or str or None

Define the link to another feature for visualization in XpViz. - A string refers to the feature name of another time series. - A tuple (feature_name, channel_name) refers to a channel within another multivariate time series feature.

None
Notes

This class does not prescribe intra-sequence sampling regularity. Individual sequences may be regularly or irregularly sampled regardless of the value of asynchronous.

  • Current limitation: Xpdeep does not yet support variable-length sequences. Please pad all sequences to a uniform length before using this feature.
Tip

If your architecture requires explicit temporal information (for example, to encode absolute or relative time), consider adding a new feature timestamp of type TimeSeries[Numerical] to your schema. This feature can represent time indices or real-world timestamps aligned with the sequence entries and will be accessible by your model.

Methods:

Name Description
to_model

Convert to a TimeseriesFeatureTypeInput instance.

from_model

Instantiate from a json response.

Attributes:

Name Type Description
items ItemType
name Literal['TIMESERIES']
asynchronous bool
channel tuple[str, str] | str | None

items: ItemType #

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

asynchronous: bool = attrs.field(default=False, kw_only=True) #

channel: tuple[str, str] | str | None = attrs.field(default=None, kw_only=True) #

to_model() -> TimeseriesFeatureTypeInput #

Convert to a TimeseriesFeatureTypeInput instance.

Returns:

Type Description
TimeseriesFeatureTypeInput

Model-level representation of the time series feature, including its temporal structure and asynchronicity flag.

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

    Returns
    -------
    TimeseriesFeatureTypeInput
        Model-level representation of the time series feature, including its
        temporal structure and asynchronicity flag.
    """
    return TimeseriesFeatureTypeInput(
        name=self.name,
        items=self.items.to_model(),
        asynchronous=self.asynchronous,
        channel=list(self.channel)
        if isinstance(self.channel, tuple)
        # TODO(Tanguy): replace with `else self.channel`
        # https://gitlab.xpdeep.com/xpdeep/xpdeep-client/-/issues/331
        else [self.channel, "0"]
        if self.channel is not None
        else None,
    )

from_model(feature_type_input: TimeseriesFeatureTypeInput) -> TimeSeriesFeature[ItemType] #

Instantiate from a json response.

Source code in src/xpdeep/dataset/feature/feature_types/time_series.py
@staticmethod
def from_model(feature_type_input: TimeseriesFeatureTypeInput) -> TimeSeriesFeature[ItemType]:
    """Instantiate from a json response."""
    channel_as_tuple: tuple[str, str] | str | None = (
        feature_type_input.channel
        if not isinstance(feature_type_input.channel, list)
        else tuple(feature_type_input.channel)  # type:ignore[assignment]
    )

    return TimeSeriesFeature(
        asynchronous=bool(feature_type_input.asynchronous),
        channel=channel_as_tuple,
        items=cast(ItemType, feature_type_from_model(feature_type_input.items)),
    )

UnivariateTimeSeriesFeature #

Alias type representing a univariate time series.

This feature models a temporal sequence of numerical values observed over time, corresponding to a single channel or variable. It is equivalent to a TimeSeriesFeature composed of a single NumericalFeature.

Parameters:

Name Type Description Default

asynchronous #

str
False

channel #

str
None

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/time_series.py
def __attrs_post_init__(self) -> None:
    """Update categories."""
    self.items = NumericalFeature()

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()

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),
    )