sklearndf.wrapper.numpy.TransformerNPDF#
- class sklearndf.wrapper.numpy.TransformerNPDF(delegate, column_names=None)[source]#
Adapter class that delegates to
TransformerDF
and accepts numpy arrays in addition topandas
data frames and series.Converts all numpy arrays to pandas series or data frames before deferring to the delegate estimator, and passes through pandas objects unchanged.
For use in meta-estimators that internally hand numpy arrays on to sub-estimators.
- Bases:
TransformerDF
,EstimatorNPDF
[~T_DelegateTransformerDF]- Generic types:
~T_DelegateTransformerDF(bound=
TransformerDF
)- Metaclasses:
- Parameters:
delegate (
EstimatorNPDF
) – the sklearndf estimator to invoke after transforming the incoming numpy arrays to pandas data frames or seriescolumn_names (
Union
[Sequence
[str
],Callable
[[],Sequence
[str
]],None
]) – optional column names to use for the pandas data frame derived from the features numpy array; passed either as a sequence of strings, or as a function that dynamically provides the column names
Method summary
Make an unfitted clone of this estimator.
Fit this estimator using the given inputs.
Fit this transformer using the given inputs, then transform the inputs.
See
sklearn.utils.get_metadata_routing()
Get the parameters for this estimator.
Inverse-transform the given inputs.
See
sklearn.utils.set_output()
Set the parameters of this estimator.
Render this object as an expression.
Transform the given inputs.
Attribute summary
Name assigned to an
Index
or aSeries
with the names of the features used to fit aEstimatorDF
.Name assigned to a
Series
with the original feature names before transformation.The pandas column index with the names of the features used to fit this estimator.
A pandas series, mapping the output features resulting from the transformation to the original input features.
A pandas column index with the names of the features produced by this transformer
True
if this object is fitted,False
otherwise.The number of features used to fit this estimator.
The number of outputs used to fit this estimator.
The native estimator underlying this estimator.
The name(s) of the output(s) this estimator was fitted to, or
None
if this estimator was not fitted to any outputs.The sklearndf estimator to invoke after transforming the incoming numpy arrays to pandas data frames or series.
Column names to use for the pandas data frame derived from the features numpy array.
Definitions
- clone()#
Make an unfitted clone of this estimator.
- Return type:
- Returns:
the unfitted clone
- fit(X, y=None, **fit_params)#
Fit this estimator using the given inputs.
- Parameters:
X (
Union
[ndarray
[tuple
[int
,...
],dtype
[Any
]],spmatrix
,Series
,DataFrame
]) – input data frame with observations as rows and features as columnsy (
Union
[ndarray
[tuple
[int
,...
],dtype
[Any
]],Series
,DataFrame
,None
]) – an optional series or data frame with one or more outputsfit_params (
Any
) – additional keyword parameters as required by specific estimator implementations
- Return type:
- Returns:
self
- fit_transform(X, y=None, **fit_params)[source]#
Fit this transformer using the given inputs, then transform the inputs.
- Parameters:
X (
Union
[ndarray
[tuple
[int
,...
],dtype
[Any
]],DataFrame
]) – input data frame with observations as rows and features as columnsy (
Union
[ndarray
[tuple
[int
,...
],dtype
[Any
]],Series
,DataFrame
,None
]) – an optional series or data frame with one or more outputsfit_params (
Any
) – additional keyword parameters as required by specific transformer implementations
- Return type:
- Returns:
the transformed inputs
- get_metadata_routing()#
See
sklearn.utils.get_metadata_routing()
- get_params(deep=True)#
Get the parameters for this estimator.
- inverse_transform(X)[source]#
Inverse-transform the given inputs.
The inputs must have the same features as the inputs used to fit this transformer. The features can be provided in any order since they are identified by their column names.
- set_output(*, transform=None)#
See
sklearn.utils.set_output()
- set_params(**params)#
Set the parameters of this estimator.
Valid parameter keys can be obtained by calling
get_params()
.- Parameters:
params (
Any
) – the estimator parameters to set- Return type:
- Returns:
self
- to_expression()#
Render this object as an expression.
- Return type:
- Returns:
the expression representing this object
- transform(X)[source]#
Transform the given inputs.
The inputs must have the same features as the inputs used to fit this transformer. The features can be provided in any order since they are identified by their column names.
- COL_FEATURE = 'feature'#
Name assigned to an
Index
or aSeries
with the names of the features used to fit aEstimatorDF
.
- COL_FEATURE_ORIGINAL = 'feature_original'#
Name assigned to a
Series
with the original feature names before transformation.
-
column_names:
Union
[Sequence
[str
],Callable
[[],Sequence
[str
]],None
]# Column names to use for the pandas data frame derived from the features numpy array.
-
delegate:
TypeVar
(T_DelegateTransformerDF
, bound=TransformerDF
)# The sklearndf estimator to invoke after transforming the incoming numpy arrays to pandas data frames or series.
- property feature_names_in_: Index#
The pandas column index with the names of the features used to fit this estimator.
- Raises:
AttributeError – this estimator is not fitted
- property feature_names_original_: Series#
A pandas series, mapping the output features resulting from the transformation to the original input features.
The index of the resulting series consists of the names of the output features; the corresponding values are the names of the original input features.
- Raises:
AttributeError – this transformer is not fitted
- property feature_names_out_: Index#
A pandas column index with the names of the features produced by this transformer
- Raises:
AttributeError – this transformer is not fitted
- property n_features_in_: int#
The number of features used to fit this estimator.
- Raises:
AttributeError – this estimator is not fitted
- property n_outputs_: int#
The number of outputs used to fit this estimator.
- Raises:
AttributeError – this estimator is not fitted
- property native_estimator: BaseEstimator#
The native estimator underlying this estimator.
This can be another estimator that this estimator delegates to, otherwise the native estimator is
self
.
- property output_names_: list[str] | None#
The name(s) of the output(s) this estimator was fitted to, or
None
if this estimator was not fitted to any outputs.- Raises:
AttributeError – this estimator is not fitted