I am trying to fit a linear model without intercept (forcing the intercept to 0) using sklearn's RANSAC: RANdom SAmple Consensus algorithm. In LinearRegression one can easily set fit_intercept=False. However, this option does not seem to exist in RANSAC's list of possible parameters. Is this functionality not implemented? How should one do it? What are alternatives to sklearn's RANSAC to objectively select inliers and outliers, that allow setting the intercept to 0?
The implementation should look like this, but it raises an error:
from sklearn.linear_model import RANSACRegressor
ransac_regressor = RANSACRegressor(fit_intercept=False)
RANSAC is a wrapper around other linear regressors to implement them using random sampling consesus, thus you can simply set the base_estimator to fit_intercept=False:
from sklearn.linear_model import RANSACRegressor, LinearRegression
ransac_lm = RANSACRegressor(base_estimator=LinearRegression(fit_intercept=False))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With