TargetTransformer¶
-
class
hcrystalball.preprocessing.
TargetTransformer
(estimator, y_transformer, omit_inverse_transformation=False)[source]¶ Bases:
sklearn.base.TransformerMixin
,sklearn.base.BaseEstimator
Enable transformation of the target.
Wrapper for applying an estimator to a transformed version of the target y and automatically transforming back predictions
Methods Summary
fit
(X[, y])Fit after reshaping and rescaling the target
fit_transform
(X[, y])Fit to data, then transform it.
get_params
([deep])Get parameters for this estimator.
Provide access to named steps for
Pipeline
predict
(X[, y])Ensure correct estimator.predict with scaled target values
score
(X[, y])Ensures correct estimator.score with scaled target values
set_params
(**params)Set the parameters of this estimator.
transform
(X[, y])Transforms the features
Methods Documentation
-
fit
(X, y=None)[source]¶ Fit after reshaping and rescaling the target
Reshape target to 2d, call fit_transform on 2d, return to 1d form and fit estimator on transformed target
- Parameters
X (Any) – Ignored.
y (numpy.ndarray) – Target values.
- Returns
Fitted target transformer
- Return type
-
fit_transform
(X, y=None, **fit_params)¶ Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Parameters
X ({array-like, sparse matrix, dataframe} of shape (n_samples, n_features)) –
y (ndarray of shape (n_samples,), default=None) – Target values.
**fit_params (dict) – Additional fit parameters.
- Returns
X_new – Transformed array.
- Return type
ndarray array of shape (n_samples, n_features_new)
-
get_params
(deep=True)¶ Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
named_steps
()[source]¶ Provide access to named steps for
Pipeline
- Returns
Dictionary of steps
- Return type
-
predict
(X, y=None)[source]¶ Ensure correct estimator.predict with scaled target values
- Parameters
X (numpy.ndarray) – Input features.
y (numpy.ndarray) – Target values.
- Returns
Results of estimators prediction
- Return type
-
score
(X, y=None)[source]¶ Ensures correct estimator.score with scaled target values
- Parameters
X (numpy.ndarray) – Input features.
y (numpy.ndarray) – Target values.
- Returns
Results of estimators score function
- Return type
Any
-
set_params
(**params)¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.
-
transform
(X, y=None)[source]¶ Transforms the features
- Parameters
X (numpy.ndarray) – Input features.
y (Any) – Ignored.
- Returns
Result of estimator transform
- Return type
-