Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Created February 26, 2018 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinThoma/6e7714fd4774b5185ac7c3ace9a5b780 to your computer and use it in GitHub Desktop.
Save MartinThoma/6e7714fd4774b5185ac7c3ace9a5b780 to your computer and use it in GitHub Desktop.
#!/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