# 1.导包import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits
from sklearn.preprocessing import MinMaxScaler, StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import SVC
from sklearn.naive_bayes import MultinomialNB
from sklearn.ensemble import AdaBoostClassifier
from sklearn.metrics import accuracy_score
# 2.加载数据并探索# 加载数据
digits = load_digits()
data = digits.data
# 数据探索print(data.shape)# 查看第一幅图像print(digits.images[0])# 第一幅图像代表的数字含义print(digits.target[0])# 将第一幅图像显示出来
plt.imshow(digits.images[0])
plt.show()
(1797,64)[[0.0.5.13.9.1.0.0.][0.0.13.15.10.15.5.0.][0.3.15.2.0.11.8.0.][0.4.12.0.0.8.8.0.][0.5.8.0.0.9.8.0.][0.4.11.0.1.12.7.0.][0.2.14.5.10.12.0.0.][0.0.6.13.10.0.0.0.]]0
Process finished with exit code 0
knn 准确率: 0.9799703264094956
svm 准确率: 0.9985163204747775
bayes 准确率:0.8835311572700296
tree 准确率:0.9955489614243324
ada 准确率: 0.9933234421364985
Process finished with exit code 0