Class: HuberRegressor
L2-regularized linear regression model that is robust to outliers.
The Huber Regressor optimizes the squared loss for the samples where |(y \- Xw \- c) / sigma| < epsilon
and the absolute loss for the samples where |(y \- Xw \- c) / sigma| > epsilon
, where the model coefficients w
, the intercept c
and the scale sigma
are parameters to be optimized. The parameter sigma makes sure that if y is scaled up or down by a certain factor, one does not need to rescale epsilon to achieve the same robustness. Note that this does not take into account the fact that the different features of X may be of different scales.
The Huber loss function has the advantage of not being heavily influenced by the outliers while not completely ignoring their effect.
Read more in the User Guide
Constructors
new HuberRegressor()
new HuberRegressor(
opts
?):HuberRegressor
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.alpha ? | number | Strength of the squared L2 regularization. Note that the penalty is equal to `alpha * |
opts.epsilon ? | number | The parameter epsilon controls the number of samples that should be classified as outliers. The smaller the epsilon, the more robust it is to outliers. Epsilon must be in the range \[1, inf) . |
opts.fit_intercept ? | boolean | Whether or not to fit the intercept. This can be set to false if the data is already centered around the origin. |
opts.max_iter ? | number | Maximum number of iterations that scipy.optimize.minimize(method="L-BFGS-B") should run for. |
opts.tol ? | number | The iteration will stop when `max{ |
opts.warm_start ? | boolean | This is useful if the stored attributes of a previously used model has to be reused. If set to false , then the coefficients will be rewritten for every call to fit. See the Glossary. |
Returns HuberRegressor
Defined in generated/linear_model/HuberRegressor.ts:27
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/linear_model/HuberRegressor.ts:25 |
_isInitialized | boolean | false | generated/linear_model/HuberRegressor.ts:24 |
_py | PythonBridge | undefined | generated/linear_model/HuberRegressor.ts:23 |
id | string | undefined | generated/linear_model/HuberRegressor.ts:20 |
opts | any | undefined | generated/linear_model/HuberRegressor.ts:21 |
Accessors
coef_
Get Signature
get coef_():
Promise
<any
>
Features got by optimizing the L2-regularized Huber loss.
Returns Promise
<any
>
Defined in generated/linear_model/HuberRegressor.ts:373
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/linear_model/HuberRegressor.ts:469
intercept_
Get Signature
get intercept_():
Promise
<number
>
Bias.
Returns Promise
<number
>
Defined in generated/linear_model/HuberRegressor.ts:396
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/linear_model/HuberRegressor.ts:444
n_iter_
Get Signature
get n_iter_():
Promise
<number
>
Number of iterations that scipy.optimize.minimize(method="L-BFGS-B")
has run for.
Returns Promise
<number
>
Defined in generated/linear_model/HuberRegressor.ts:494
outliers_
Get Signature
get outliers_():
Promise
<any
>
A boolean mask which is set to true
where the samples are identified as outliers.
Returns Promise
<any
>
Defined in generated/linear_model/HuberRegressor.ts:519
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/linear_model/HuberRegressor.ts:74
scale_
Get Signature
get scale_():
Promise
<number
>
The value by which |y \- Xw \- c|
is scaled down.
Returns Promise
<number
>
Defined in generated/linear_model/HuberRegressor.ts:421
Methods
dispose()
dispose():
Promise
<void
>
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Returns Promise
<void
>
Defined in generated/linear_model/HuberRegressor.ts:126
fit()
fit(
opts
):Promise
<any
>
Fit the model according to the given training data.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Weight given to each sample. |
opts.X ? | ArrayLike | Training vector, where n_samples is the number of samples and n_features is the number of features. |
opts.y ? | ArrayLike | Target vector relative to X. |
Returns Promise
<any
>
Defined in generated/linear_model/HuberRegressor.ts:143
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/linear_model/HuberRegressor.ts:187
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/linear_model/HuberRegressor.ts:87
predict()
predict(
opts
):Promise
<any
>
Predict using the linear model.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | Samples. |
Returns Promise
<any
>
Defined in generated/linear_model/HuberRegressor.ts:221
score()
score(
opts
):Promise
<number
>
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.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
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.y ? | ArrayLike | True values for X . |
Returns Promise
<number
>
Defined in generated/linear_model/HuberRegressor.ts:255
set_fit_request()
set_fit_request(
opts
):Promise
<any
>
Request metadata passed to the fit
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:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in fit . |
Returns Promise
<any
>
Defined in generated/linear_model/HuberRegressor.ts:301
set_score_request()
set_score_request(
opts
):Promise
<any
>
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:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in score . |
Returns Promise
<any
>
Defined in generated/linear_model/HuberRegressor.ts:339