Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sklearn RANSAC without intercept

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)
like image 970
ouranos Avatar asked Jan 25 '26 11:01

ouranos


1 Answers

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))
like image 132
JE_Muc Avatar answered Jan 27 '26 02:01

JE_Muc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!