Statistical learning--the settings and estimators object


一些设置和预测器对象

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>

png

data = digits.images.reshape((digits.images.shape[0],-1))  #将8*8的image改成长度为64的矢量
data.shape
(1797, 64)

文章作者: lovelyfrog
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 lovelyfrog !
  目录