
Doing some linear regression this summer for a logistic company, I got interested in finding ways to automatically assign the linear regression to the data, even if it’s noisy.
from sklearn.linear_model import RANSACRegressor
from sklearn.datasets import make_regression
X, y = make_regression(
n_samples=200, n_features=2, noise=4.0, random_state=0)
reg = RANSACRegressor(random_state=0).fit(X, y)
print("Regression score is: {}".format(reg.score(X, y))
print(reg.predict(X[:1,]))
Check out the sklearn docs for more info on how the RANSACRegressor is implemented. If you feel in a crazy mood, definately check out the this explanatory song:
Image source: CSE Buffalo If you enjoyed this post I’m looking forward to the next advent hoho.
Software used:
- Python
- Sklearn