Skip to content

Instantly share code, notes, and snippets.

@clementpoiret
Created February 9, 2020 17:54
Show Gist options
  • Save clementpoiret/ec81c8cf66076b1cb468c9463f67f771 to your computer and use it in GitHub Desktop.
Save clementpoiret/ec81c8cf66076b1cb468c9463f67f771 to your computer and use it in GitHub Desktop.
# Model's Definition and Training
model = LinearRegression(fit_intercept = True)
model.fit(X_train, y_train)
# Creating test sets
X_test = 2 * np.random.random_sample((10, 1))
y_test = gradient * X_test + w0 + 0.1 * np.random.random_sample((10, 1))
# Score
r2 = model.score(X_test, y_test)
print("Gradient : {}\nBias w0 : {}\nR2 : {}".format(model.coef_,
model.intercept_,
r2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment