一些设置和预测器对象
from sklearn import datasets
iris = datasets.load_iris()
data = iris.data
data.shape #150 个 observations 每个有4个feature
(150, 4)
when the data is not initially in (n_samples,n_features) shape ,it need preprocess
digits = datasets.load_digits()
digits.images.shape
(1797, 8, 8)
import matplotlib.pyplot as plt
%matplotlib inline
plt.imshow(digits.images[0],cmap=plt.cm.gray_r)
<matplotlib.image.AxesImage at 0x15a20373080>
data = digits.images.reshape((digits.images.shape[0],-1)) #将8*8的image改成长度为64的矢量
data.shape
(1797, 64)