Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/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), y_true)
y_pred = regressor.predict(x)
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