Skip to content

feature

Represent a feature object.

Classes:

Name Description
BaseFeature

Base Feature used if no convenient available feature.

NumericalFeature

Numerical feature.

CategoricalFeature

Categorical feature.

MultivariateNumericalFeature

MultivariateNumericalFeature feature.

UnivariateTimeSeries

UnivariateTimeSerie feature.

MultivariateTimeSeries

MultivariateTimeSeries feature.

ImageFeature

Image feature.

Attributes:

Name Type Description
ExposedFeature
Feature

__all__ = ['BaseFeature', 'CategoricalFeature', 'ExposedFeature', 'ExposedIndexMetadata', 'Feature', 'ImageFeature', 'MultivariateNumericalFeature', 'MultivariateTimeSeries', 'NumericalFeature', 'UnivariateTimeSeries'] #

ExposedFeature = ExposedCategoricalFeature | ExposedCategoricalFeatureList | ExposedNumericalFeature | ExposedMultivariateNumericalFeature | ExposedMultivariateTimeSeries | ExposedUnivariateTimeSeries | ExposedImage #

EXPOSED_FEATURE_TYPE = TypeVar('EXPOSED_FEATURE_TYPE', bound=ExposedFeature) #

FEATURE_AUGMENTATION_TYPE = TypeVar('FEATURE_AUGMENTATION_TYPE') #

Feature = ImageFeature | NumericalFeature | CategoricalFeature | MultivariateNumericalFeature | UnivariateTimeSeries | MultivariateTimeSeries #

AbstractDataElement #

Represent a schema column, with a name.

Parameters:

Name Type Description Default

name #

str
required

Attributes:

Name Type Description
name str

name: str #

TargetableFeature #

A feature that can be a target.

Parameters:

Name Type Description Default

is_target #

bool
False

Attributes:

Name Type Description
is_target bool

is_target: bool = False #

BaseFeature #

Base Feature used if no convenient available feature.

Methods:

Name Description
from_exposed

BaseFeature from ExposedBaseFeature.

as_exposed

BaseFeature as ExposedBaseFeature.

from_exposed(exposed_feature: ExposedBaseFeature) -> Self #

BaseFeature from ExposedBaseFeature.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_feature: ExposedBaseFeature) -> Self:
    """BaseFeature from ExposedBaseFeature."""
    return cls(**msgspec_asdict(exposed_feature))

as_exposed() -> ExposedBaseFeature #

BaseFeature as ExposedBaseFeature.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(self) -> ExposedBaseFeature:
    """BaseFeature as ExposedBaseFeature."""
    return ExposedBaseFeature(**_attrs_asdict(self))

ExplainableFeature #

Define a feature object.

Parameters:

Name Type Description Default

preprocessor #

TorchPreprocessor | SklearnPreprocessor | IdentityPreprocessor

The feature preprocessor function used to preprocess the data.

required

feature_augmentation #

ImageFeatureAugmentation | None

Feature augmentation functions, currently supported: ImageFeatureAugmentation.

None

Methods:

Name Description
as_exposed

Feature as exposed feature.

from_exposed

Feature from exposed feature.

Attributes:

Name Type Description
preprocessor TorchPreprocessor | SklearnPreprocessor | IdentityPreprocessor
feature_augmentation ImageFeatureAugmentation | None

preprocessor: TorchPreprocessor | SklearnPreprocessor | IdentityPreprocessor = field(kw_only=True) #

feature_augmentation: ImageFeatureAugmentation | None = field(kw_only=True, default=None) #

as_exposed(*, with_augmentation: bool) -> EXPOSED_FEATURE_TYPE | ExposedFeatureWithAugmentation #

Feature as exposed feature.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(self, *, with_augmentation: bool) -> EXPOSED_FEATURE_TYPE | ExposedFeatureWithAugmentation:
    """Feature as exposed feature."""
    raise NotImplementedError

from_exposed(exposed_feature: EXPOSED_FEATURE_TYPE) -> Self #

Feature from exposed feature.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_feature: EXPOSED_FEATURE_TYPE) -> Self:
    """Feature from exposed feature."""
    raise NotImplementedError

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
from_exposed

NumericalFeature from ExposedNumericalFeature.

as_exposed

NumericalFeature as ExposedNumericalFeature or ExposedFeatureWithAugmentation.

from_exposed(exposed_feature: ExposedNumericalFeature) -> Self #

NumericalFeature from ExposedNumericalFeature.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_feature: ExposedNumericalFeature) -> Self:
    """NumericalFeature from ExposedNumericalFeature."""
    return cast("Self", cls._from_exposed(exposed_feature))

as_exposed(*, with_augmentation: bool = False) -> ExposedNumericalFeature | ExposedFeatureWithAugmentation #

as_exposed(
    *, with_augmentation: Literal[False] = False
) -> ExposedNumericalFeature
as_exposed(
    *, with_augmentation: Literal[True]
) -> ExposedFeatureWithAugmentation
as_exposed(
    *, with_augmentation: bool = False
) -> (
    ExposedNumericalFeature | ExposedFeatureWithAugmentation
)

NumericalFeature as ExposedNumericalFeature or ExposedFeatureWithAugmentation.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(
    self, *, with_augmentation: bool = False
) -> ExposedNumericalFeature | ExposedFeatureWithAugmentation:
    """NumericalFeature as ExposedNumericalFeature or ExposedFeatureWithAugmentation."""
    results = self._as_exposed(ExposedNumericalFeature, with_augmentation=with_augmentation)

    if with_augmentation:
        return cast("ExposedFeatureWithAugmentation", results)

    return cast("ExposedNumericalFeature", results)

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

Methods:

Name Description
from_exposed

CategoricalFeature from ExposedCategoricalFeature.

as_exposed

ExposedCategoricalFeature as ExposedNumericalFeature or ExposedFeatureWithAugmentation.

Attributes:

Name Type Description
categories list[str | int | bool]

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

from_exposed(exposed_feature: ExposedCategoricalFeature) -> Self #

CategoricalFeature from ExposedCategoricalFeature.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_feature: ExposedCategoricalFeature) -> Self:
    """CategoricalFeature from ExposedCategoricalFeature."""
    return cast("Self", cls._from_exposed(exposed_feature))

as_exposed(*, with_augmentation: bool = False) -> ExposedCategoricalFeature | ExposedFeatureWithAugmentation #

as_exposed(
    *, with_augmentation: Literal[False] = False
) -> ExposedCategoricalFeature
as_exposed(
    *, with_augmentation: Literal[True]
) -> ExposedFeatureWithAugmentation
as_exposed(
    *, with_augmentation: bool = False
) -> (
    ExposedCategoricalFeature
    | ExposedFeatureWithAugmentation
)

ExposedCategoricalFeature as ExposedNumericalFeature or ExposedFeatureWithAugmentation.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(
    self, *, with_augmentation: bool = False
) -> ExposedCategoricalFeature | ExposedFeatureWithAugmentation:
    """ExposedCategoricalFeature as ExposedNumericalFeature or ExposedFeatureWithAugmentation."""
    results = self._as_exposed(ExposedCategoricalFeature, with_augmentation=with_augmentation)

    if with_augmentation:
        return cast("ExposedFeatureWithAugmentation", results)

    return cast("ExposedCategoricalFeature", results)

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

Methods:

Name Description
from_exposed

MultivariateNumericalFeature from ExposedMultivariateNumericalFeature.

as_exposed

MultivariateNumericalFeature as ExposedMultivariateNumericalFeature or ExposedFeatureWithAugmentation.

Attributes:

Name Type Description
channel_names list[str] | None

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

from_exposed(exposed_feature: ExposedMultivariateNumericalFeature) -> Self #

MultivariateNumericalFeature from ExposedMultivariateNumericalFeature.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_feature: ExposedMultivariateNumericalFeature) -> Self:
    """MultivariateNumericalFeature from ExposedMultivariateNumericalFeature."""
    return cast("Self", cls._from_exposed(exposed_feature))

as_exposed(*, with_augmentation: bool = False) -> ExposedMultivariateNumericalFeature | ExposedFeatureWithAugmentation #

as_exposed(
    *, with_augmentation: Literal[False] = False
) -> ExposedMultivariateNumericalFeature
as_exposed(
    *, with_augmentation: Literal[True]
) -> ExposedFeatureWithAugmentation
as_exposed(
    *, with_augmentation: bool = False
) -> (
    ExposedMultivariateNumericalFeature
    | ExposedFeatureWithAugmentation
)

MultivariateNumericalFeature as ExposedMultivariateNumericalFeature or ExposedFeatureWithAugmentation.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(
    self, *, with_augmentation: bool = False
) -> ExposedMultivariateNumericalFeature | ExposedFeatureWithAugmentation:
    """MultivariateNumericalFeature as ExposedMultivariateNumericalFeature or ExposedFeatureWithAugmentation."""
    results = self._as_exposed(ExposedMultivariateNumericalFeature, with_augmentation=with_augmentation)

    if with_augmentation:
        return cast("ExposedFeatureWithAugmentation", results)

    return cast("ExposedMultivariateNumericalFeature", results)

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

Methods:

Name Description
from_exposed

UnivariateTimeSeries from ExposedUnivariateTimeSeries.

as_exposed

UnivariateTimeSeries as ExposedUnivariateTimeSeries or ExposedFeatureWithAugmentation.

Attributes:

Name Type Description
asynchronous bool
mirrored_channel str | None

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

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

from_exposed(exposed_feature: ExposedUnivariateTimeSeries) -> Self #

UnivariateTimeSeries from ExposedUnivariateTimeSeries.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_feature: ExposedUnivariateTimeSeries) -> Self:
    """UnivariateTimeSeries from ExposedUnivariateTimeSeries."""
    return cast("Self", cls._from_exposed(exposed_feature))

as_exposed(*, with_augmentation: bool = False) -> ExposedUnivariateTimeSeries | ExposedFeatureWithAugmentation #

as_exposed(
    *, with_augmentation: Literal[False] = False
) -> ExposedUnivariateTimeSeries
as_exposed(
    *, with_augmentation: Literal[True]
) -> ExposedFeatureWithAugmentation
as_exposed(
    *, with_augmentation: bool = False
) -> (
    ExposedUnivariateTimeSeries
    | ExposedFeatureWithAugmentation
)

UnivariateTimeSeries as ExposedUnivariateTimeSeries or ExposedFeatureWithAugmentation.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(
    self, *, with_augmentation: bool = False
) -> ExposedUnivariateTimeSeries | ExposedFeatureWithAugmentation:
    """UnivariateTimeSeries as ExposedUnivariateTimeSeries or ExposedFeatureWithAugmentation."""
    results = self._as_exposed(ExposedUnivariateTimeSeries, with_augmentation=with_augmentation)

    if with_augmentation:
        return cast("ExposedFeatureWithAugmentation", results)

    return cast("ExposedUnivariateTimeSeries", results)

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

Methods:

Name Description
from_exposed

ExposedMultivariateTimeSeries from ExposedMultivariateTimeSeries.

as_exposed

MultivariateTimeSeries as ExposedMultivariateTimeSeries or ExposedFeatureWithAugmentation.

Attributes:

Name Type Description
asynchronous bool
channel_names list[str] | None

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

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

from_exposed(exposed_feature: ExposedMultivariateTimeSeries) -> Self #

ExposedMultivariateTimeSeries from ExposedMultivariateTimeSeries.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_feature: ExposedMultivariateTimeSeries) -> Self:
    """ExposedMultivariateTimeSeries from ExposedMultivariateTimeSeries."""
    return cast("Self", cls._from_exposed(exposed_feature))

as_exposed(*, with_augmentation: bool = False) -> ExposedMultivariateTimeSeries | ExposedFeatureWithAugmentation #

as_exposed(
    *, with_augmentation: Literal[False] = False
) -> ExposedMultivariateTimeSeries
as_exposed(
    *, with_augmentation: Literal[True]
) -> ExposedFeatureWithAugmentation
as_exposed(
    *, with_augmentation: bool = False
) -> (
    ExposedMultivariateTimeSeries
    | ExposedFeatureWithAugmentation
)

MultivariateTimeSeries as ExposedMultivariateTimeSeries or ExposedFeatureWithAugmentation.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(
    self, *, with_augmentation: bool = False
) -> ExposedMultivariateTimeSeries | ExposedFeatureWithAugmentation:
    """MultivariateTimeSeries as ExposedMultivariateTimeSeries or ExposedFeatureWithAugmentation."""
    results = self._as_exposed(ExposedMultivariateTimeSeries, with_augmentation=with_augmentation)

    if with_augmentation:
        return cast("ExposedFeatureWithAugmentation", results)

    return cast("ExposedMultivariateTimeSeries", results)

ImageFeature #

Image feature.

It represents image feature objects.

Parameters:

Name Type Description Default

serialized_width #

int | None
None

serialized_height #

int | None
None

serialized_byte_format #

str
'PNG'

Methods:

Name Description
from_exposed

NumericalFeature from ExposedImage.

as_exposed

NumericalFeature as ExposedImage or ExposedFeatureWithAugmentation.

Attributes:

Name Type Description
serialized_width int | None
serialized_height int | None
serialized_byte_format str

serialized_width: int | None = None #

serialized_height: int | None = None #

serialized_byte_format: str = 'PNG' #

from_exposed(exposed_feature: ExposedImage) -> Self #

NumericalFeature from ExposedImage.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_feature: ExposedImage) -> Self:
    """NumericalFeature from ExposedImage."""
    return cast("Self", cls._from_exposed(exposed_feature))

as_exposed(*, with_augmentation: bool = False) -> ExposedImage | ExposedFeatureWithAugmentation #

as_exposed(
    *, with_augmentation: Literal[False] = False
) -> ExposedImage
as_exposed(
    *, with_augmentation: Literal[True]
) -> ExposedFeatureWithAugmentation
as_exposed(
    *, with_augmentation: bool = False
) -> ExposedImage | ExposedFeatureWithAugmentation

NumericalFeature as ExposedImage or ExposedFeatureWithAugmentation.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(self, *, with_augmentation: bool = False) -> ExposedImage | ExposedFeatureWithAugmentation:
    """NumericalFeature as ExposedImage or ExposedFeatureWithAugmentation."""
    results = self._as_exposed(ExposedImage, with_augmentation=with_augmentation)

    if with_augmentation:
        return cast("ExposedFeatureWithAugmentation", results)

    return cast("ExposedImage", results)

IndexMetadata #

Represents an index metadata, automatically added to the schema, cf doc dataset/concept.

Methods:

Name Description
as_exposed

Generate the corresponding exposed ExposedIndexMetadata.

from_exposed

Create IndexMetadata from ExposedIndexMetadata.

as_exposed() -> ExposedIndexMetadata #

Generate the corresponding exposed ExposedIndexMetadata.

Source code in src/xpdeep/dataset/schema/feature/feature.py
def as_exposed(self) -> ExposedIndexMetadata:
    """Generate the corresponding exposed ExposedIndexMetadata."""
    return ExposedIndexMetadata(name=self.name)

from_exposed(exposed_metadata: ExposedIndexMetadata) -> Self #

Create IndexMetadata from ExposedIndexMetadata.

Source code in src/xpdeep/dataset/schema/feature/feature.py
@classmethod
def from_exposed(cls, exposed_metadata: ExposedIndexMetadata) -> Self:
    """Create IndexMetadata from ExposedIndexMetadata."""
    return cls(name=exposed_metadata.name)