Created
October 9, 2012 04:42
-
-
Save masayang/3856660 to your computer and use it in GitHub Desktop.
Xが3次元
This file contains hidden or 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 import linear_model | |
import matplotlib.pyplot as plt | |
X = np.array([[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 3.1]]) | |
Y = np.array([0.1, 1.1, 1.8, 2.7]) | |
regr = linear_model.LinearRegression() | |
regr.fit(X, Y) | |
print 'Coefficients:', regr.coef_ | |
print 'Residual sum of squares: %f' % np.mean((regr.predict(X) - Y) ** 2) | |
print 'Variance score %f' % regr.score(X, Y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment