Robust line model estimation using RANSAC
In this example we see how to robustly fit a line model to faulty data using the RANSAC (random sample consensus) algorithm.
Firstly the data are generated by adding a gaussian noise to a linear function. Then, the outlier points are added to the data set.
RANSAC iteratively estimates the parameters from the data set. At each iteration the following steps are performed:
Select
min_samplesrandom samples from the original data and check whether the set of data is valid (seeis_data_validoption).Estimate a model on the random subset (
model_cls.from_estimate(*data[random_subset]) and check whether the estimated model is valid (seeis_model_validoption).Classify all the data points as either inliers or outliers by calculating the residuals using the estimated model (
model_cls.residuals(*data)) - all data samples with residuals smaller than the are considered as inliers.

