Features

The AutoCarver.features module defines a set of features used in the AutoCarver project. This module includes classes and functions to handle different types of features, such as qualitative and quantitative features.

Features

class AutoCarver.features.Features(categoricals: list[str] | None = None, quantitatives: list[str] | None = None, ordinals: dict[str, list[str]] | None = None, config: FeaturesConfig | None = None)

A set of typed features

Build a Features collection from column names.

Parameters:
  • categoricals (list[str], optional) – Categorical column names, by default None.

  • quantitatives (list[str], optional) – Quantitative column names, by default None.

  • ordinals (dict[str, list[str]], optional) – Ordinal column names mapped to their ordered value list, by default None.

  • config (FeaturesConfig, optional) – Collection-level config propagated to each feature, by default None.

Warning

At least one of categoricals, quantitatives or ordinals must be provided. To build a Features from already-instantiated feature objects, use Features.from_list() instead.

property categoricals: list[CategoricalFeature]

Returns all categorical features

classmethod load(features_json: dict) Features

Allows one to load a set of Features

Parameters:

features_json (dict) – Dictionary of serialized Features

Returns:

Loaded Features.

Return type:

Features

property names: list[str]

Returns names of all features

property ordinals: list[OrdinalFeature]

Returns all ordinal features

property qualitatives: list[OrdinalFeature | CategoricalFeature]

Returns all qualitative features

property quantitatives: list[QuantitativeFeature]

Returns all quantitative features

property summary: DataFrame

Summary of discretization process for all features

to_json(light_mode: bool = False) dict

Serializes Features for JSON saving

Parameters:

light_mode (bool, optional) – Whether or not to serialize in light mode (without statistics and history), by default False

property versions: list[str]

Returns versions of all features

Qualitatitve features

class AutoCarver.features.CategoricalFeature(name: str, *, max_n_chars: int = 50)

Defines a categorical feature

property has_default: bool

Whether the feature has default values.

property history: DataFrame

Combination history as a DataFrame (empty when no history yet).

Stored internally as a list of dicts in _history for JSON serialization; the DataFrame is rebuilt on access. Append entries with historize().

property summary: list[dict]

Summary of feature’s discretization process.

class AutoCarver.features.OrdinalFeature(name: str, values: list[str])

Defines an ordinal feature

Parameters:

values (list[str]) – Ordered list of all unique values for the feature

property has_default: bool

Whether the feature has default values.

property history: DataFrame

Combination history as a DataFrame (empty when no history yet).

Stored internally as a list of dicts in _history for JSON serialization; the DataFrame is rebuilt on access. Append entries with historize().

property summary: list[dict]

Summary of feature’s discretization process.

Quantitative features

class AutoCarver.features.QuantitativeFeature(name: str)

Defines a quantitative feature

property has_default: bool

Whether the feature has default values.

property history: DataFrame

Combination history as a DataFrame (empty when no history yet).

Stored internally as a list of dicts in _history for JSON serialization; the DataFrame is rebuilt on access. Append entries with historize().

property summary: list[dict]

Summary of feature’s discretization process.