After you have fit the model, you can either call the coef
and intercept_
attributes to see what the coefficients and the intercept are respectively.
But this would involve writing a constructed formula for your model. My recommendation is once you build your model, make the predictions and score it against the true y
values -
from sklearn.metrics import mean_squared_error
mean_squared_error(y_test, y_pred) # y_test are true values, y_pred are the predictions that you get by calling regression.predict()
If the goal is to calculate distances, you sklearn.metrics
convenience functions instead of looking for the equation and hand-computing it yourself. The manual way to do that will be -
import numpy as np
y_pred = np.concatenate(np.ones(X_test.shape[0]), X_test) * np.insert(clf.coef_,0,clf.intercept_)
sq_err = np.square(y_pred - y_test)
mean_sq_err = np.mean(sq_err)