Skip to content

time_series

Time series feature types.

Classes:

Name Description
TimeSeriesFeature

Feature representing a temporal sequence of sub-features.

UnivariateTimeSeriesFeature

Alias type representing a univariate time series.

MultivariateTimeSeriesFeature

Feature representing a multivariate time series.

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

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