섹션 6 작업형 2 정확도 오류 원인 질문드립니다! Classification metrics can't handle a mix of binary and continuous targets
0
from sklearn.model_selection import train_test_split
X_tr,X_val,y_tr,y_val=train_test_split(train.drop('Attrition_Flag',axis=1),train['Attrition_Flag'],test_size=0.2,random_state=2023)
from sklearn.ensemble import RandomForestClassifier
rf=RandomForestClassifier(random_state=2023)
rf.fit(X_tr,y_tr)
pred=rf.predict_proba(X_val)
from sklearn.metrics import accuracy_score
# 정확도
print(accuracy_score(y_val, pred[:,1]))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-63-aa6b6ce781f8> in <cell line: 10>()
8
9 # 정확도
---> 10 print(accuracy_score(y_val, pred[:,1]))
2 frames
/usr/local/lib/python3.10/dist-packages/sklearn/metrics/_classification.py in _check_targets(y_true, y_pred)
93
94 if len(y_type) > 1:
---> 95 raise ValueError(
96 "Classification metrics can't handle a mix of {0} and {1} targets".format(
97 type_true, type_pred
ValueError: Classification metrics can't handle a mix of binary and continuous targets
혹은
print(accuracy_score(y_val, pred)) 실행 시,
오류2번 Classification metrics can't handle a mix of binary and continuous-multioutput targets해당 코드로 제출까지는 잘 되고 있습니다.
그러나 정확도 측정 시 오류가 발생하여, 제출에 문제가 있는 것인가 불안하여 오류 현상 문의드립니다..!
답변 1
평가지표 F1 스코어 질문드립니다.
0
9
2
작업형 2 기출7회분에서
0
23
2
작업형2 모의문제1 (30강)
0
25
2
수강 기간 연장 문의 드립니다.
0
31
2
수강 계획과 관련해 문의 드립니다.
0
26
2
작업형1 - 연습문제 16~39 풀이는 몇강을 보면 되나요?
0
49
2
작업형 1 -연습문제 4-6
0
35
2
작업형 1 유형 부분
0
42
2
작업형 1 (삭제예정, 구 버전)
0
51
2
수강기간 연장 문의드립니다.
0
37
2
2유형 레이블 인코딩 VS 원핫 인코딩
0
37
3
수강기간 연장 문의드립니다.
0
44
2
인덱스 슬라이싱
0
36
2
질문 드립니다.
0
50
2
강의 내용 관련 질문드립니다~
0
46
2
수강 연장 문의
0
63
2
강의자료 일괄 다운로드
0
58
2
수강기간 연장 문의드립니다
0
48
2
list 문제 질문드립니다~
0
38
2
빅분기 실기 12회 재도전
0
63
2
강의 기간 연장 가능여부 검토 요청건
0
51
2
수강기간 연장 문의 드립니다
0
46
2
수강기간 연장 문의드립니다
0
52
2
질문이요
0
57
2





