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
andy
with optional parametersfit_params
and returns a transformed version ofX
.- Parameters
X (array-like of shape (n_samples, n_features)) – Input samples.
y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) – Target values (None for unsupervised transformations).
**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.
- 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
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
estimator instance
- transform(X, y=None)[source]¶
Transforms the features
- Parameters
X (numpy.ndarray) – Input features.
y (Any) – Ignored.
- Returns
Result of estimator transform
- Return type