标签:ict col info import color res png target dict
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model
from sklearn import datasets
%matplotlib inline
diabetes = datasets.load_diabetes()
x_train = diabetes.data[:-20]
y_train = diabetes.target[:-20]
x_test = diabetes.data[-20:]
y_test = diabetes.target[-20:]
#gs = plt.GridSpec(2,2)
plt.figure(figsize=(8,12))
for f in range(0,10):
xi_test = x_test[:,f]
xi_train = x_train[:,f]
xi_test = xi_test[:,np.newaxis]
xi_train = xi_train[:,np.newaxis]
linreg = linear_model.LinearRegression()
linreg.fit(xi_train,y_train)
y = linreg.predict(xi_test)
#s1 = fig.add_subplot(gs[0,f])
plt.subplot(5,2,f+1)
plt.scatter(xi_test,y_test,color=‘k‘)
plt.plot(xi_test,y,color=‘b‘,linewidth=3)
plt.show()
标签:ict col info import color res png target dict
原文地址:https://www.cnblogs.com/wei23/p/13151572.html