!pip install sklearn
#scikit-learnからデータの読み込み
from sklearn import datasets
iris = datasets.load_iris()
# アヤメの分類に使用するデータの確認
print(iris.data)
print(iris.target)
# アヤメの分類の学習
# 学習用データと検証用データに分割
from sklearn.model_selection import train_test_split as split
x_train, x_test, y_train, y_test = split(iris.data,iris.target,train_size=0.8,test_size=0.2)
# model作成
from sklearn.ensemble import GradientBoostingClassifier
model = GradientBoostingClassifier()
# 学習実行
model.fit(x_train, y_train)
# modelの評価
from sklearn.metrics import accuracy_score, confusion_matrix, ConfusionMatrixDisplay
# 評価の実行
y_pred = model.predict(x_test)
# 正解率
Accuracy = accuracy_score(y_test, y_pred)
print('正解率:', Accuracy)
#
cm = confusion_matrix(y_test, y_pred)
!pip install matplotlib
import matplotlib.pyplot as plt
disp = ConfusionMatrixDisplay(cm)
disp.plot()
plt.show()