Skip to content

Instantly share code, notes, and snippets.

@masayang
Created October 9, 2012 04:42
Show Gist options
  • Save masayang/3856660 to your computer and use it in GitHub Desktop.
Save masayang/3856660 to your computer and use it in GitHub Desktop.
Xが3次元
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