tempor.methods.preprocessing.encoding.static.plugin_static_onehot_encoder module¶
One-hot encoding for static data.
- class tempor.methods.preprocessing.encoding.static.plugin_static_onehot_encoder.StaticOneHotEncoderParams(features: ~typing.List[str] | None = None, categories: typing_extensions.Literal[auto] | ~typing.List = 'auto', drop: None | typing_extensions.Literal[first, if_binary] | ~typing.List = None, dtype: ~typing.Type = <class 'float'>, handle_unknown: typing_extensions.Literal[error, ignore, infrequent_if_exist] = 'error', min_frequency: int | float | None = None, max_categories: int | None = None, feature_name_combiner: typing_extensions.Literal[concat] | ~typing.Callable = 'concat')[source]¶
Bases:
objectInitialization parameters for
StaticOneHotEncoder.See
sklearn.preprocessing.OneHotEncoder.Note
sparse_outputis always set toFalse.-
categories : Literal[auto] | list =
'auto'¶ See
categoriesinsklearn.preprocessing.OneHotEncoder
-
drop : None | Literal[first] | Literal[if_binary] | list =
None¶ See
dropinsklearn.preprocessing.OneHotEncoder
- dtype¶
See
dtypeinsklearn.preprocessing.OneHotEncoderalias of
float
-
handle_unknown : Literal[error] | Literal[ignore] | Literal[infrequent_if_exist] =
'error'¶ See
handle_unknowninsklearn.preprocessing.OneHotEncoder
-
min_frequency : int | float | None =
None¶ See
min_frequencyinsklearn.preprocessing.OneHotEncoder
-
max_categories : int | None =
None¶ See
max_categoriesinsklearn.preprocessing.OneHotEncoder
-
feature_name_combiner : Literal[concat] | Callable =
'concat'¶ See
feature_name_combinerinsklearn.preprocessing.OneHotEncoder
-
categories : Literal[auto] | list =
- class tempor.methods.preprocessing.encoding.static.plugin_static_onehot_encoder.StaticOneHotEncoder(**params: Any)[source]¶
Bases:
BaseEncoderOne-hot encoding for the static data.
See
sklearn.preprocessing.OneHotEncoderfor details.Specify
featureslist to encode only a subset of the features.- Parameters:¶
- **params : Any
Parameters and defaults as defined in
StaticOneHotEncoderParams.
Example
>>> from tempor import plugin_loader >>> >>> dataset = plugin_loader.get("prediction.temporal.dummy_prediction", plugin_type="datasource").load() >>> >>> # Get static data with some categorical features. >>> import numpy as np >>> import pandas as pd >>> np.random.seed(777) >>> from tempor.data.samples import StaticSamples >>> static_df = dataset.static.dataframe() >>> static_df["categorical_feat_1"] = pd.Categorical( ... np.random.choice(["a", "b", "c"], size=(len(static_df),)) ... ) >>> static_df["categorical_feat_2"] = pd.Categorical(np.random.choice(["D", "E"], size=(len(static_df),))) >>> dataset.static = StaticSamples.from_dataframe(static_df) >>> >>> # Load the encoder: >>> enc = plugin_loader.get( ... "preprocessing.encoding.static.static_onehot_encoder", ... features=["categorical_feat_1", "categorical_feat_2"], ... ) >>> >>> # Fit: >>> enc.fit(dataset) StaticOneHotEncoder(...) >>> >>> # Encode: >>> encoded = enc.transform(dataset)- ParamsDefinition¶
alias of
StaticOneHotEncoderParams
-
category : ClassVar[plugin_typing.PluginCategory] =
'preprocessing.encoding.static'¶ Plugin category, such as
'prediction.one_off.classification'. Must be set by the plugin class using@register_plugin.
-
name : ClassVar[plugin_typing.PluginName] =
'static_onehot_encoder'¶ Plugin name, such as
'my_nn_classifier'. Must be set by the plugin class using@register_plugin.
-
plugin_type : ClassVar[plugin_typing.PluginTypeArg] =
'method'¶ Plugin type, such as
'method'. May be optionally set by the plugin class using@register_plugin, else will set the default plugin type.
- params : StaticOneHotEncoderParams¶