DocumentationClassesTheilSenRegressor

Class: TheilSenRegressor

Theil-Sen Estimator: robust multivariate regression model.

The algorithm calculates least square solutions on subsets with size n_subsamples of the samples in X. Any value of n_subsamples between the number of features and samples leads to an estimator with a compromise between robustness and efficiency. Since the number of least square solutions is “n_samples choose n_subsamples”, it can be extremely large and can therefore be limited with max_subpopulation. If this limit is reached, the subsets are chosen randomly. In a final step, the spatial median (or L1 median) is calculated of all least square solutions.

Read more in the User Guide.

Python Reference

Constructors

new TheilSenRegressor()

new TheilSenRegressor(opts?): TheilSenRegressor

Parameters

ParameterTypeDescription
opts?object-
opts.copy_X?booleanIf true, X will be copied; else, it may be overwritten.
opts.fit_intercept?booleanWhether to calculate the intercept for this model. If set to false, no intercept will be used in calculations.
opts.max_iter?numberMaximum number of iterations for the calculation of spatial median.
opts.max_subpopulation?numberInstead of computing with a set of cardinality ‘n choose k’, where n is the number of samples and k is the number of subsamples (at least number of features), consider only a stochastic subpopulation of a given maximal size if ‘n choose k’ is larger than max_subpopulation. For other than small problem sizes this parameter will determine memory usage and runtime if n_subsamples is not changed. Note that the data type should be int but floats such as 1e4 can be accepted too.
opts.n_jobs?numberNumber of CPUs to use during the cross validation. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details.
opts.n_subsamples?numberNumber of samples to calculate the parameters. This is at least the number of features (plus 1 if fit_intercept=true) and the number of samples as a maximum. A lower number leads to a higher breakdown point and a low efficiency while a high number leads to a low breakdown point and a high efficiency. If undefined, take the minimum number of subsamples leading to maximal robustness. If n_subsamples is set to n_samples, Theil-Sen is identical to least squares.
opts.random_state?numberA random number generator instance to define the state of the random permutations generator. Pass an int for reproducible output across multiple function calls. See Glossary.
opts.tol?numberTolerance when calculating spatial median.
opts.verbose?booleanVerbose mode when fitting the model.

Returns TheilSenRegressor

Defined in generated/linear_model/TheilSenRegressor.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/linear_model/TheilSenRegressor.ts:23
_isInitializedbooleanfalsegenerated/linear_model/TheilSenRegressor.ts:22
_pyPythonBridgeundefinedgenerated/linear_model/TheilSenRegressor.ts:21
idstringundefinedgenerated/linear_model/TheilSenRegressor.ts:18
optsanyundefinedgenerated/linear_model/TheilSenRegressor.ts:19

Accessors

breakdown_

Get Signature

get breakdown_(): Promise<number>

Approximated breakdown point.

Returns Promise<number>

Defined in generated/linear_model/TheilSenRegressor.ts:409


coef_

Get Signature

get coef_(): Promise<ArrayLike>

Coefficients of the regression model (median of distribution).

Returns Promise<ArrayLike>

Defined in generated/linear_model/TheilSenRegressor.ts:355


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/TheilSenRegressor.ts:517


intercept_

Get Signature

get intercept_(): Promise<number>

Estimated intercept of regression model.

Returns Promise<number>

Defined in generated/linear_model/TheilSenRegressor.ts:382


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/TheilSenRegressor.ts:490


n_iter_

Get Signature

get n_iter_(): Promise<number>

Number of iterations needed for the spatial median.

Returns Promise<number>

Defined in generated/linear_model/TheilSenRegressor.ts:436


n_subpopulation_

Get Signature

get n_subpopulation_(): Promise<number>

Number of combinations taken into account from ‘n choose k’, where n is the number of samples and k is the number of subsamples.

Returns Promise<number>

Defined in generated/linear_model/TheilSenRegressor.ts:463


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/linear_model/TheilSenRegressor.ts:87

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/TheilSenRegressor.ts:141


fit()

fit(opts): Promise<any>

Fit linear model.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training data.
opts.y?ArrayLikeTarget values.

Returns Promise<any>

Defined in generated/linear_model/TheilSenRegressor.ts:158


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

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

Returns Promise<any>

Defined in generated/linear_model/TheilSenRegressor.ts:199


init()

init(py): Promise<void>

Initializes the underlying Python resources.

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

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/linear_model/TheilSenRegressor.ts:100


predict()

predict(opts): Promise<any>

Predict using the linear model.

Parameters

ParameterTypeDescription
optsobject-
opts.X?anySamples.

Returns Promise<any>

Defined in generated/linear_model/TheilSenRegressor.ts:235


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

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample 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?ArrayLikeTrue values for X.

Returns Promise<number>

Defined in generated/linear_model/TheilSenRegressor.ts:271


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

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in score.

Returns Promise<any>

Defined in generated/linear_model/TheilSenRegressor.ts:319