To find the original coefficients back, you need to use the keyword fit_intercept=Falsewhen building linear regression.
import numpy as np
from sklearn import linear_model
b = np.array([3,5,7])
x = np.array([[1,6,9],
[2,7,7],
[3,4,5]])
y = np.array([96,90,64])
clf = linear_model.LinearRegression(fit_intercept=False)
clf.fit(x, y)
print clf.coef_
print np.dot(x, clf.coef_)
Using fit_intercept=Falseprevents the object LinearRegressionfrom working x - x.mean(axis=0), which otherwise it would execute (and fix the average using a constant offset y = xb + c)) or equivalent by adding a column 1to x.
, transpose 1D- ( , ).