Skip to content

feature_types

Feature types module.

Classes:

Name Description
NumericalFeature

Numerical feature.

CategoricalFeature

Categorical feature.

MultivariateNumericalFeature

MultivariateNumericalFeature feature.

UnivariateTimeSeries

UnivariateTimeSerie feature.

MultivariateTimeSeries

MultivariateTimeSeries feature.

ImageFeature

Image feature.

FeatureTypeConvertor

Class for converting exposed features type into feature types.

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.

Parameters:

Name Type Description Default

name #

Literal[str]
'numerical'

Methods:

Name Description
from_exposed

Instantiate a NumericalFeature from ExposedNumerical.

Attributes:

Name Type Description
name Literal['numerical']
as_exposed ExposedNumerical

NumericalFeature as ExposedNumericalFeature or ExposedFeatureWithAugmentation.

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

as_exposed: ExposedNumerical #

NumericalFeature as ExposedNumericalFeature or ExposedFeatureWithAugmentation.

from_exposed(exposed_feature: ExposedNumerical) -> NumericalFeature #

Instantiate a NumericalFeature from ExposedNumerical.

Source code in src/xpdeep/dataset/feature/feature_types.py
@staticmethod
def from_exposed(exposed_feature: ExposedNumerical) -> "NumericalFeature":
    """Instantiate a NumericalFeature from ExposedNumerical."""
    return NumericalFeature(name=cast("Literal['numerical']", exposed_feature.name))

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 | int | bool]

Categories, automatically inferred from the preprocessor after the fitting step. None if not inferred yet.

None

name #

Literal[str]
'categorical'

Methods:

Name Description
from_exposed

Instantiate a CategoricalFeature from ExposedCategorical.

Attributes:

Name Type Description
name Literal['categorical']
categories list[str | int | bool] | None
as_exposed ExposedCategorical

As ExposedCategorical.

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

categories: list[str | int | bool] | None = field(default=None, kw_only=True) #

as_exposed: ExposedCategorical #

As ExposedCategorical.

from_exposed(exposed_feature: ExposedCategorical) -> CategoricalFeature #

Instantiate a CategoricalFeature from ExposedCategorical.

Source code in src/xpdeep/dataset/feature/feature_types.py
@staticmethod
def from_exposed(exposed_feature: ExposedCategorical) -> "CategoricalFeature":
    """Instantiate a CategoricalFeature from ExposedCategorical."""
    return CategoricalFeature(
        categories=exposed_feature.categories,
    )

MultivariateNumericalFeature #

MultivariateNumericalFeature feature.

It represents numerical data points divided into several channels. Oppositely as time serie features, there is no time relationship between points here.

Parameters:

Name Type Description Default

channel_names #

List[str] | None

List of channel names, optional.

None

name #

Literal[str]
'multivariate_numerical'

Methods:

Name Description
from_exposed

Instantiate a MultivariateNumericalFeature from an ExposedVectorNumerical.

Attributes:

Name Type Description
name Literal['multivariate_numerical']
channel_names list[str] | None
as_exposed ExposedVectorNumerical

As ExposedVectorNumerical.

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

channel_names: list[str] | None = field(default=None, kw_only=True) #

as_exposed: ExposedVectorNumerical #

As ExposedVectorNumerical.

from_exposed(exposed_feature: ExposedVectorNumerical) -> MultivariateNumericalFeature #

Instantiate a MultivariateNumericalFeature from an ExposedVectorNumerical.

Source code in src/xpdeep/dataset/feature/feature_types.py
@staticmethod
def from_exposed(exposed_feature: ExposedVectorNumerical) -> "MultivariateNumericalFeature":
    """Instantiate a MultivariateNumericalFeature from an ExposedVectorNumerical."""
    return MultivariateNumericalFeature(
        channel_names=exposed_feature.channel_names,
    )

UnivariateTimeSeries #

UnivariateTimeSerie feature.

It represents a time serie with a single channel, synchronized (no dynamic time warping required) or not.

The DTW will be applied automatically if this feature is required.

Parameters:

Name Type Description Default

asynchronous #

int

Whether the time serie is asynchronous (dynamic time warping will be automatically applied server side) or not.

False.

mirrored_channel #

str | None

Used in XpViz. Indeed, if the same channel is used for both input (as a lookback, under a first feature object) and target (as a horizon to predict, under a second feature object), this parameter may be specified to visualize on the same curve both features, (the lookback and its corresponding horizon).

None

name #

Literal[str]
'univariate_time_series'

Methods:

Name Description
from_exposed

Instantiate a UnivariateTimeSeries from an ExposedUnivariateTimeSeries.

Attributes:

Name Type Description
name Literal['univariate_time_series']
asynchronous bool
mirrored_channel str | None
as_exposed ExposedUnivariateTimeSeries

As ExposedUnivariateTimeSeries.

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

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

mirrored_channel: str | None = field(default=None, kw_only=True) #

as_exposed: ExposedUnivariateTimeSeries #

As ExposedUnivariateTimeSeries.

from_exposed(exposed_feature: ExposedUnivariateTimeSeries) -> UnivariateTimeSeries #

Instantiate a UnivariateTimeSeries from an ExposedUnivariateTimeSeries.

Source code in src/xpdeep/dataset/feature/feature_types.py
@staticmethod
def from_exposed(exposed_feature: ExposedUnivariateTimeSeries) -> "UnivariateTimeSeries":
    """Instantiate a UnivariateTimeSeries from an ExposedUnivariateTimeSeries."""
    return UnivariateTimeSeries(
        asynchronous=exposed_feature.asynchronous,
        mirrored_channel=exposed_feature.mirrored_channel,
    )

MultivariateTimeSeries #

MultivariateTimeSeries feature.

This class represents a multivariate time series (multiple channels), synchronized (no dynamic time warping required) or not.

The DTW will be applied automatically if this feature is required.

Parameters:

Name Type Description Default

asynchronous #

int

Whether the time serie is asynchronous (dynamic time warping will be automatically applied server side) or not.

False.

channel_names #

List[str] | None

List of channel names, optional.

None

name #

Literal[str]
'multivariate_time_series'

Methods:

Name Description
from_exposed

Instantiate a MultivariateTimeSeries from a ExposedMultivariateTimeSeries.

Attributes:

Name Type Description
name Literal['multivariate_time_series']
asynchronous bool
channel_names list[str] | None
as_exposed ExposedMultivariateTimeSeries

As ExposedMultivariateTimeSeries.

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

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

channel_names: list[str] | None = field(default=None, kw_only=True) #

as_exposed: ExposedMultivariateTimeSeries #

As ExposedMultivariateTimeSeries.

from_exposed(exposed_feature: ExposedMultivariateTimeSeries) -> MultivariateTimeSeries #

Instantiate a MultivariateTimeSeries from a ExposedMultivariateTimeSeries.

Source code in src/xpdeep/dataset/feature/feature_types.py
@staticmethod
def from_exposed(exposed_feature: ExposedMultivariateTimeSeries) -> "MultivariateTimeSeries":
    """Instantiate a MultivariateTimeSeries from a ExposedMultivariateTimeSeries."""
    return MultivariateTimeSeries(
        asynchronous=exposed_feature.asynchronous,
        channel_names=exposed_feature.channel_names,
    )

ImageFeature #

Image feature.

It represents image feature objects.

Parameters:

Name Type Description Default

name #

Literal[str]
'image'

serialized_width #

int | None
None

serialized_height #

int | None
None

serialized_byte_format #

str
'PNG'

Methods:

Name Description
from_exposed

Instantiate an ImageFeature from an ExposedImage.

Attributes:

Name Type Description
name Literal['image']
serialized_width int | None
serialized_height int | None
serialized_byte_format str
as_exposed ExposedImage

As ExposedImage.

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

serialized_width: int | None = None #

serialized_height: int | None = None #

serialized_byte_format: str = 'PNG' #

as_exposed: ExposedImage #

As ExposedImage.

from_exposed(exposed_feature: ExposedImage) -> ImageFeature #

Instantiate an ImageFeature from an ExposedImage.

Source code in src/xpdeep/dataset/feature/feature_types.py
@staticmethod
def from_exposed(exposed_feature: ExposedImage) -> "ImageFeature":
    """Instantiate an ImageFeature from an ExposedImage."""
    return ImageFeature(
        serialized_width=exposed_feature.serialized_width,
        serialized_height=exposed_feature.serialized_height,
        serialized_byte_format=exposed_feature.serialized_byte_format,
    )

FeatureTypeConvertor #

Class for converting exposed features type into feature types.

For instance, it recognizes an ExposedNumerical and instantiate corresponding NumericalFeature.

Methods:

Name Description
from_exposed

Convert exposed feature type into feature type.

from_exposed(exposed_feature_type: ExposedNumerical | ExposedVectorNumerical | ExposedCategorical | ExposedUnivariateTimeSeries | ExposedMultivariateTimeSeries | ExposedImage) -> NumericalFeature | MultivariateNumericalFeature | CategoricalFeature | UnivariateTimeSeries | MultivariateTimeSeries | ImageFeature #

Convert exposed feature type into feature type.

Source code in src/xpdeep/dataset/feature/feature_types.py
@classmethod
def from_exposed(
    cls,
    exposed_feature_type: ExposedNumerical
    | ExposedVectorNumerical
    | ExposedCategorical
    | ExposedUnivariateTimeSeries
    | ExposedMultivariateTimeSeries
    | ExposedImage,
) -> (
    NumericalFeature
    | MultivariateNumericalFeature
    | CategoricalFeature
    | UnivariateTimeSeries
    | MultivariateTimeSeries
    | ImageFeature
):
    """Convert exposed feature type into feature type."""
    match exposed_feature_type:
        case ExposedNumerical():
            return NumericalFeature.from_exposed(exposed_feature_type)
        case ExposedVectorNumerical():
            return MultivariateNumericalFeature.from_exposed(exposed_feature_type)
        case ExposedCategorical():
            return CategoricalFeature.from_exposed(exposed_feature_type)
        case ExposedUnivariateTimeSeries():
            return UnivariateTimeSeries.from_exposed(exposed_feature_type)
        case ExposedMultivariateTimeSeries():
            return MultivariateTimeSeries.from_exposed(exposed_feature_type)
        case ExposedImage():
            return ImageFeature.from_exposed(exposed_feature_type)