from sklearn.linear_model import LinearRegression
a = 0.5
b = 1.0
// x from 0 to 10
x = 30 * np.random.random(20)
// y = a*x + b with noise
y = a * x + b + np.random.normal(size=x.shape)
// create a linear regression classifier
clf = LinearRegression()
clf.fit(x[:, np.newaxis], y)
// predict y from the data
x_new = np.linspace(0, 30, 100)
y_new = clf.predict(x_new[:, np.newaxis])
After Change
// create a linear regression model
model = LinearRegression()
model.fit(x, y)
// predict y from the data
x_new = np.linspace(0, 30, 100)
y_new = model.predict(x_new[:, np.newaxis])