Fitting a robust regression model using RANSAC
Linear regression models can be heavily impacted by the presence of outliers. In certain situations, a very small subset of our data can have a big effect on the estimated model coefficients. There are many statistical tests that can be used to detect outliers, which are beyond the scope of the book. However, removing outliers always requires our own judgment as a data scientist, as well as our domain knowledge.
As an alternative to throwing out outliers, we will look at a robust method of regression using the RANdom SAmple Consensus (RANSAC) algorithm, which fits a regression model to a subset of the data, the so-called inliers.
We can summarize the iterative RANSAC algorithm as follows:
Select a random number of samples to be inliers and fit the model.
Test all other data points against the fitted model and add those points that fall within a user-given tolerance to the inliers.
Refit the model using all inliers.
Estimate the error of the fitted...