_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › Python-ConfusionMatrix

#iris 一危一誤 襷り鍵
import numpy as np
import pandas as pd
from sklearn.datasets import load_iris
iris = load_iris()
iris.data
iris.feature_names
iris.target
iris.target_names


iris_df = pd.DataFrame(iris.data, columns=iris.feature_names)
iris_df["target"] = iris.target 
iris_df["target_names"] = iris.target_names[iris.target]
iris_df[:5]


#誤, ろ語誤 蠍
from sklearn.model_selection import train_test_split
train_set, test_set = train_test_split(iris_df, test_size = 0.3)

train_set.shape
test_set.shape


#kNN
import sklearn.neighbors as nn
knn = nn.KNeighborsClassifier(n_neighbors = 1)

#
knn.fit(X=train_set.ix[:, [0,1,2,3]], y=train_set.target)

#ろ
pred = knn.predict(X=test_set.ix[:, [0,1,2,3]])


#焔ロろ
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report

#confusion_matrix
#classification_report
c_mat = confusion_matrix(test_set.target.values, pred)
print('\n\nConfusion Matrix\n', c_mat)
print('\n', classification_report(test_set.target.values, pred, target_names=iris.target_names))

蟆郁骸
print('\n\nConfusion Matrix\n', c_mat)
print('\n', classification_report(test_set.target.values, pred, target_names=iris.target_names))



Confusion Matrix
 [[12  0  0]
 [ 0 21  1]
 [ 0  1 10]]

              precision    recall  f1-score   support

     setosa       1.00      1.00      1.00        12
 versicolor       0.95      0.95      0.95        22
  virginica       0.91      0.91      0.91        11

avg / total       0.96      0.96      0.96        45

  • precision(襯): 豸♀骸 れ螳 朱 螳?
  • recall() : 覦襯願 覿襯 一危一 觜?
  • f1-score(F1) : 襯螻 譟壱蠏 --> 願姥 覲企 .

覘...TP(true positive) 焔 覘 り襴 企れ 襷, 讌 豺郁..
confusion matrix 螳() 襷朱 襷襦 譬蟇磯.
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

螻褐 語 蠍一 殊企. ( 貂)