섹션 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
작업형1_연습문제1 section2
0
6
2
수강기간 연장 문의드립니다
0
9
1
작업형2 모의문제2_updated2026.10
0
17
2
수강기간 연장문의
0
19
1
작업형 2 질문
0
26
2
강의 연장 관련하여 문의드립니다.
0
30
1
섹션7 자료 다운로드
0
31
2
작업형 1 연습문제 Section12
0
29
2
수강기간 연장 문의
0
40
1
안녕하세요, 혹시 수강기간 연장이 가능할까요?
0
37
2
판다스 강의자료는 어디서 받을 수 있나요?
0
43
2
작업형2 모의고사3 자료 업데이트 요청
0
44
4
수강 연장가능여부 문의드립니다!
0
45
2
수강기간 연장 문의드립니다!
0
41
2
최빈값
0
45
2
수강 가이드라인
0
41
2
수강 연장 가능 여부 문의
0
59
2
강의 구매했는데 교재 필수일까요
0
49
2
수강기간 연장 가부 문의드립니다.
0
44
2
수강기간 연장이 가능한지 양해를 구하며 문의를 드립니다.
0
44
2
작업형2 모의문제2에서 drop이랑 인코딩
0
56
3
인코딩을 다 꼭 해봐야하는지
0
55
2
안녕하세요? 강사님 질문있습니다.(인코딩관련)
0
65
2
이진분류에서 양성 클래스가 0일 때 평가 방법
0
48
2





