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.
Constructors
new TheilSenRegressor()
new TheilSenRegressor(
opts?):TheilSenRegressor
Parameters
| Parameter | Type | Description | 
|---|---|---|
| opts? | object | - | 
| opts.copy_X? | boolean | If true, X will be copied; else, it may be overwritten. | 
| opts.fit_intercept? | boolean | Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations. | 
| opts.max_iter? | number | Maximum number of iterations for the calculation of spatial median. | 
| opts.max_subpopulation? | number | Instead 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? | number | Number of CPUs to use during the cross validation. undefinedmeans 1 unless in ajoblib.parallel_backendcontext.\-1means using all processors. See Glossary for more details. | 
| opts.n_subsamples? | number | Number 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. Ifundefined, 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? | number | A 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? | number | Tolerance when calculating spatial median. | 
| opts.verbose? | boolean | Verbose mode when fitting the model. | 
Returns TheilSenRegressor
Defined in generated/linear_model/TheilSenRegressor.ts:25
Properties
| Property | Type | Default value | Defined in | 
|---|---|---|---|
| _isDisposed | boolean | false | generated/linear_model/TheilSenRegressor.ts:23 | 
| _isInitialized | boolean | false | generated/linear_model/TheilSenRegressor.ts:22 | 
| _py | PythonBridge | undefined | generated/linear_model/TheilSenRegressor.ts:21 | 
| id | string | undefined | generated/linear_model/TheilSenRegressor.ts:18 | 
| opts | any | undefined | generated/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
| Parameter | Type | 
|---|---|
| pythonBridge | PythonBridge | 
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
| Parameter | Type | Description | 
|---|---|---|
| opts | object | - | 
| opts.X? | ArrayLike[] | Training data. | 
| opts.y? | ArrayLike | Target 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
| Parameter | Type | Description | 
|---|---|---|
| opts | object | - | 
| opts.routing? | any | A MetadataRequestencapsulating 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
| Parameter | Type | 
|---|---|
| py | PythonBridge | 
Returns Promise<void>
Defined in generated/linear_model/TheilSenRegressor.ts:100
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/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
| 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), wheren_samples_fittedis 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/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
| Parameter | Type | Description | 
|---|---|---|
| opts | object | - | 
| opts.sample_weight? | string|boolean | Metadata routing for sample_weightparameter inscore. | 
Returns Promise<any>