Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- matplotlib
- append()
- count()
- nan
- pandas
- Machine Learning
- 반복문
- hierarchical_clustering
- IN
- function
- Dictionary
- 분류 결과표
- sklearn
- analizer
- del
- 최댓값
- insert()
- 최솟값
- DataFrame
- 덴드로그램
- wcss
- len()
- elbow method
- numpy
- list
- string
- DataAccess
- data
- Python
- dendrogram
Archives
- Today
- Total
개발공부
sklearn 라이브러리의 분류 결과표 Confusion Matrix (분류 문제의 인공지능 성능 평가 방법) 본문
Python/Machine Learning
sklearn 라이브러리의 분류 결과표 Confusion Matrix (분류 문제의 인공지능 성능 평가 방법)
mscha 2022. 5. 9. 20:06분류 결과표 (Confusion Matrix)
타겟의 원래 클래스와 모형이 예측한 클래스가 일치하는지를 갯수로 센 결과를 표로 나타낸 것
정답 클래스는 행(row)으로 예측한 클래스는 열(column)로 나타낸다.

두개의 클래스로 분류할 때
이진 분류 결과표(Binary Confusion Matrix)
클래스가 0과 1 두종류 밖에 없는 이진 분류의 경우
일반적으로 클래스 이름을 양성(Positive)과 음성(Negative)로 표시한다.


sklearn 라이브러리를 이용한 confusion metrix
>>> from sklearn.metrics import confusion_matrix, accuracy_score, classification_report
#정답 라벨인 y_test와 학습한 결과로 얻은 예측 값 y_pred 이용
>>> cm = confusion_matrix(y_test, y_pred)
>>> cm
array([[51, 4],
[ 8, 17]], dtype=int64)
# 정확도 직접계산
>>> (51 + 17) / cm.sum()
0.85
# 정확도 함수이용
>>> accuracy_score(y_test, y_pred)
0.85
>>> print(classification_report(y_test, y_pred))
precision recall f1-score support
0 0.86 0.93 0.89 55
1 0.81 0.68 0.74 25
accuracy 0.85 80
macro avg 0.84 0.80 0.82 80
weighted avg 0.85 0.85 0.85 80'Python > Machine Learning' 카테고리의 다른 글
| 스케일러나 인코더의 fit(), transform(), fit_transform() 함수 사용법 (0) | 2022.05.10 |
|---|---|
| [Machine Learning] 신규 데이터 예측하는 순서 (0) | 2022.05.09 |
| Multiple Linear Regression 실습 예제 (0) | 2022.05.09 |
| Linear Regression (0) | 2022.05.09 |
| 데이터 전처리 기초 #5 sklearn라이브러리를 이용해 Dataset 나누기 (Training,Test) (0) | 2022.05.09 |