Created
May 8, 2017 13:52
-
-
Save juchiast/927655bb37abea346e8244b1c8ef2842 to your computer and use it in GitHub Desktop.
Approximating hidden function using scikit-learn linear regression model
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
import numpy as np | |
from sklearn.linear_model import LinearRegression | |
def f(x): | |
return 1 + 0.87*x[0] + 0.34*x[1] + 0.5*x[2] | |
X = np.random.random((2000, 3)) * 100 | |
y = [f(x) for x in X] | |
lm = LinearRegression() | |
lm.fit(X, y) | |
x = [[2, -1, 5]]; | |
print(lm.predict(x), f(x[0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment