Documentation
Classes
TransformedTargetRegressor

TransformedTargetRegressor

Meta-estimator to regress on a transformed target.

Useful for applying a non-linear transformation to the target y in regression problems. This transformation can be given as a Transformer such as the QuantileTransformer or as a function and its inverse such as np.log and np.exp.

The computation during fit is:

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new TransformedTargetRegressor(opts?: object): TransformedTargetRegressor;

Parameters

NameTypeDescription
opts?object-
opts.check_inverse?booleanWhether to check that transform followed by inverse\_transform or func followed by inverse\_func leads to the original targets. Default Value true
opts.func?anyFunction to apply to y before passing to fit. Cannot be set at the same time as transformer. The function needs to return a 2-dimensional array. If func is None, the function used will be the identity function.
opts.inverse_func?anyFunction to apply to the prediction of the regressor. Cannot be set at the same time as transformer. The function needs to return a 2-dimensional array. The inverse function is used to return predictions to the same space of the original training labels.
opts.regressor?anyRegressor object such as derived from RegressorMixin. This regressor will automatically be cloned each time prior to fitting. If regressor is None, LinearRegression is created and used.
opts.transformer?anyEstimator object such as derived from TransformerMixin. Cannot be set at the same time as func and inverse\_func. If transformer is None as well as func and inverse\_func, the transformer will be an identity transformer. Note that the transformer will be cloned during fitting. Also, the transformer is restricting y to be a numpy array.

Returns

TransformedTargetRegressor

Defined in: generated/compose/TransformedTargetRegressor.ts:25 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/compose/TransformedTargetRegressor.ts:118 (opens in a new tab)

fit()

Fit the model according to the given training data.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining vector, where n\_samples is the number of samples and n\_features is the number of features.
opts.fit_params?anyParameters passed to the fit method of the underlying regressor.
opts.y?ArrayLikeTarget values.

Returns

Promise<any>

Defined in: generated/compose/TransformedTargetRegressor.ts:135 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns

Promise<any>

Defined in: generated/compose/TransformedTargetRegressor.ts:188 (opens in a new tab)

init()

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/compose/TransformedTargetRegressor.ts:70 (opens in a new tab)

predict()

Predict using the base regressor, applying inverse.

The regressor is used to predict and the inverse\_func or inverse\_transform is applied before returning the prediction.

Signature

predict(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeSamples.
opts.predict_params?anyParameters passed to the predict method of the underlying regressor.

Returns

Promise<ArrayLike>

Defined in: generated/compose/TransformedTargetRegressor.ts:228 (opens in a new tab)

score()

Return the coefficient of determination of the prediction.

The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y\_true \- y\_pred)\*\* 2).sum() and \(v\) is the total sum of squares ((y\_true \- y\_true.mean()) \*\* 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.

Signature

score(opts: object): Promise<number>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n\_samples, n\_samples\_fitted), where n\_samples\_fitted is the number of samples used in the fitting for the estimator.
opts.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTrue values for X.

Returns

Promise<number>

Defined in: generated/compose/TransformedTargetRegressor.ts:274 (opens in a new tab)

set_score_request()

Request metadata passed to the score method.

Note that this method is only relevant if enable\_metadata\_routing=True (see sklearn.set\_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Signature

set_score_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in score.

Returns

Promise<any>

Defined in: generated/compose/TransformedTargetRegressor.ts:329 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/compose/TransformedTargetRegressor.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/compose/TransformedTargetRegressor.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/compose/TransformedTargetRegressor.ts:21 (opens in a new tab)

id

string

Defined in: generated/compose/TransformedTargetRegressor.ts:18 (opens in a new tab)

opts

any

Defined in: generated/compose/TransformedTargetRegressor.ts:19 (opens in a new tab)

Accessors

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/compose/TransformedTargetRegressor.ts:421 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/compose/TransformedTargetRegressor.ts:57 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/compose/TransformedTargetRegressor.ts:61 (opens in a new tab)

regressor_

Fitted regressor.

Signature

regressor_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/compose/TransformedTargetRegressor.ts:367 (opens in a new tab)

transformer_

Transformer used in fit and predict.

Signature

transformer_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/compose/TransformedTargetRegressor.ts:394 (opens in a new tab)