Á¤¼ºÈÆ
    code_14_20.py (±³Àç)
  http://itsys.hansung.ac.kr/cgi-bin/onlineTest/viewpy4AI/onlinePy4AI.cgi?source=src/py/Ch14/code_14_20.py



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from sklearn.datasets import load_iris 
from sklearn.model_selection import train_test_split 
from sklearn.neighbors import KNeighborsClassifier 
from sklearn import metrics 
 
iris = load_iris()
num_neigh = 5
knn = KNeighborsClassifier(n_neighbors=num_neigh) 
knn.fit(iris.data, iris.target)
 
y_pred_all = knn.predict(iris.data)
scores = metrics.accuracy_score(iris.target, y_pred_all)
print('n_neighbors°¡ {0:d}À϶§ Á¤È®µµ: {1:.3f}'.format(num_neigh, scores))
 
import matplotlib.pyplot as plt
plt.hist2d(iris.target, y_pred_all, bins=(3,3), cmap=plt.cm.jet)
plt.show()
 
from sklearn.metrics import confusion_matrix
conf_mat = confusion_matrix(iris.target, y_pred_all)
print(conf_mat)
 
plt.matshow(conf_mat)
plt.show()
cs

  µî·ÏÀÏ : 2022-12-06 [02:12] Á¶È¸ : 204 ´Ù¿î : 0   
 
¡â ÀÌÀü±Ûcode_14_22_1.py (±³Àç)
¡ä ´ÙÀ½±Ûcode_14_19.py (±³Àç)
Python for AI ½Ç½À°Ô½ÃÆÇ
¹øÈ£ ¨Ï Á¦ ¸ñ Á¶È¸ µî·ÏÀÏ
lAnaconda3 ¼³Ä¡
lColabTurtlePlus
l½Ç½À ¸ñ·Ï
lColab ½Ç½À
l½Ç½À ½Ã ÇлýµéÀÌ ÀÚÁÖÇÏ´Â ½Ç¼ö ¿¹µé
360    ¦¦❷ lcode_14_22_1.py (±³Àç) 226 12-06
359 ¦¦❶ lcode_14_20.py (±³Àç) 204 12-06
358 ¦¦❶ lcode_14_19.py (±³Àç) 161 12-06
357 ¦¦❶ lcode_14_18.py (±³Àç) 180 12-06
356 ¦¦❶ lcode_14_17.py (±³Àç) 184 12-06
355 ¦¦❶ lcode_14_16.py (±³Àç) 173 12-06
354 ¦¦❶ lcode_14_13.py (±³Àç) 171 12-06
353 ¦¦❶ llab_14_2.py (±³Àç) 216 12-06
352 ¦¦❶ lcode_14_12.py (±³Àç) 205 12-06
351 ¦¦❶ lcode_14_10_2.py (±³Àç) 169 12-06
350 ¦¦❶ lcode_14_10_1.py (±³Àç) 180 12-06
349 ¦¦❶ lcode_14_9.py (±³Àç) 186 12-06
348 ¦¦❶ llab_14_1.py (±³Àç) 183 12-06
347 ¦¦❶ lcode_14_8.py (±³Àç) 199 12-06
346 ¦¦❶ lcode_14_7.py (±³Àç) 210 12-06
345 (13Àå) ½Ã°¢ Á¤º¸¸¦ ´Ù·ç¾îº¸ÀÚ 353 02-19
344 ¦¦❶ lch13.ipynb (¿¹Á¦ Àüü) 430 03-01
343 (12Àå) ÆÇ´Ù½º·Î µ¥ÀÌÅ͸¦ ºÐ¼®Çغ¸ÀÚ 553 02-19
342 ¦¦❶ lch12.ipynb (¿¹Á¦ Àüü) 496 03-01
341 ¦¦❶ lcode_12_23.py (±³Àç) 380 02-21

[1][2][3][4][5][6][7][8][9][10]-[Next][19]