Created
February 26, 2018 17:56
-
-
Save MartinThoma/6e7714fd4774b5185ac7c3ace9a5b780 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import numpy as np | |
from sklearn.linear_model import LinearRegression | |
import sklearn.metrics | |
regressor = LinearRegression() | |
n = 4 | |
feature_dim = 2 | |
x = np.random.rand(n * feature_dim).reshape(n, feature_dim) | |
y_true = np.random.rand(n) | |
x[:, 1] = x[:, 0] | |
print(x) | |
regressor.fit(x, y_true) | |
y_pred = regressor.predict(x) | |
print(regressor) | |
print(sklearn.metrics.mean_squared_error(y_true, y_pred)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment