Documentation
Classes
RANSACRegressor

RANSACRegressor

RANSAC (RANdom SAmple Consensus) algorithm.

RANSAC is an iterative algorithm for the robust estimation of parameters from a subset of inliers from the complete data set.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new RANSACRegressor(opts?: object): RANSACRegressor;

Parameters

NameTypeDescription
opts?object-
opts.estimator?anyBase estimator object which implements the following methods:
opts.is_data_valid?anyThis function is called with the randomly selected data before the model is fitted to it: is\_data\_valid(X, y). If its return value is false the current randomly chosen sub-sample is skipped.
opts.is_model_valid?anyThis function is called with the estimated model and the randomly selected data: is\_model\_valid(model, X, y). If its return value is false the current randomly chosen sub-sample is skipped. Rejecting samples with this function is computationally costlier than with is\_data\_valid. is\_model\_valid should therefore only be used if the estimated model is needed for making the rejection decision.
opts.loss?stringString inputs, ‘absolute_error’ and ‘squared_error’ are supported which find the absolute error and squared error per sample respectively. If loss is a callable, then it should be a function that takes two arrays as inputs, the true and predicted value and returns a 1-D array with the i-th value of the array corresponding to the loss on X\[i\]. If the loss on a sample is greater than the residual\_threshold, then this sample is classified as an outlier. Default Value 'absolute_error'
opts.max_skips?numberMaximum number of iterations that can be skipped due to finding zero inliers or invalid data defined by is\_data\_valid or invalid models defined by is\_model\_valid.
opts.max_trials?numberMaximum number of iterations for random sample selection. Default Value 100
opts.min_samples?numberMinimum number of samples chosen randomly from original data. Treated as an absolute number of samples for min\_samples >= 1, treated as a relative number ceil(min\_samples \* X.shape\[0\]) for min\_samples < 1. This is typically chosen as the minimal number of samples necessary to estimate the given estimator. By default a LinearRegression estimator is assumed and min\_samples is chosen as X.shape\[1\] + 1. This parameter is highly dependent upon the model, so if a estimator other than LinearRegression is used, the user must provide a value.
opts.random_state?numberThe generator used to initialize the centers. Pass an int for reproducible output across multiple function calls. See Glossary.
opts.residual_threshold?numberMaximum residual for a data sample to be classified as an inlier. By default the threshold is chosen as the MAD (median absolute deviation) of the target values y. Points whose residuals are strictly equal to the threshold are considered as inliers.
opts.stop_n_inliers?numberStop iteration if at least this number of inliers are found.
opts.stop_probability?numberRANSAC iteration stops if at least one outlier-free set of the training data is sampled in RANSAC. This requires to generate at least N samples (iterations): Default Value 0.99
opts.stop_score?numberStop iteration if score is greater equal than this threshold.

Returns

RANSACRegressor

Defined in: generated/linear_model/RANSACRegressor.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/linear_model/RANSACRegressor.ts:171 (opens in a new tab)

fit()

Fit estimator using RANSAC algorithm.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining data.
opts.sample_weight?ArrayLikeIndividual weights for each sample raises error if sample_weight is passed and estimator fit method does not support it.
opts.y?ArrayLikeTarget values.

Returns

Promise<any>

Defined in: generated/linear_model/RANSACRegressor.ts:188 (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/linear_model/RANSACRegressor.ts:237 (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/linear_model/RANSACRegressor.ts:113 (opens in a new tab)

predict()

Predict using the estimated model.

This is a wrapper for estimator\_.predict(X).

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?any[]Input data.

Returns

Promise<any>

Defined in: generated/linear_model/RANSACRegressor.ts:274 (opens in a new tab)

score()

Return the score of the prediction.

This is a wrapper for estimator\_.score(X, y).

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?any[]Training data.
opts.y?ArrayLikeTarget values.

Returns

Promise<number>

Defined in: generated/linear_model/RANSACRegressor.ts:309 (opens in a new tab)

set_fit_request()

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:

Signature

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

Parameters

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

Returns

Promise<any>

Defined in: generated/linear_model/RANSACRegressor.ts:353 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/linear_model/RANSACRegressor.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/linear_model/RANSACRegressor.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/linear_model/RANSACRegressor.ts:21 (opens in a new tab)

id

string

Defined in: generated/linear_model/RANSACRegressor.ts:18 (opens in a new tab)

opts

any

Defined in: generated/linear_model/RANSACRegressor.ts:19 (opens in a new tab)

Accessors

estimator_

Best fitted model (copy of the estimator object).

Signature

estimator_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/linear_model/RANSACRegressor.ts:388 (opens in a new tab)

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/linear_model/RANSACRegressor.ts:563 (opens in a new tab)

inlier_mask_

Boolean mask of inliers classified as true.

Signature

inlier_mask_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/linear_model/RANSACRegressor.ts:438 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/RANSACRegressor.ts:538 (opens in a new tab)

n_skips_invalid_data_

Number of iterations skipped due to invalid data defined by is\_data\_valid.

Signature

n_skips_invalid_data_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/RANSACRegressor.ts:488 (opens in a new tab)

n_skips_invalid_model_

Number of iterations skipped due to an invalid model defined by is\_model\_valid.

Signature

n_skips_invalid_model_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/RANSACRegressor.ts:513 (opens in a new tab)

n_skips_no_inliers_

Number of iterations skipped due to finding zero inliers.

Signature

n_skips_no_inliers_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/RANSACRegressor.ts:463 (opens in a new tab)

n_trials_

Number of random selection trials until one of the stop criteria is met. It is always <= max\_trials.

Signature

n_trials_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/linear_model/RANSACRegressor.ts:413 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/linear_model/RANSACRegressor.ts:100 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/linear_model/RANSACRegressor.ts:104 (opens in a new tab)