섹션 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
수업노트가 어디에 있나요?
0
17
1
실기시험 제출관련
0
148
2
6.20 작업형 2 과적합
0
156
3
코딩팡 장업형2 베이스 라인 인코딩 종류 질문
0
48
2
로지스틱회귀, 회귀
0
47
2
회귀 문제를 풀때 질문입니다.
0
54
1
불균형 처리 후 성능이 더 낮아졌다면,
0
61
2
실기 체험 제2유형 에러 문의
0
61
1
LIGHTGBM 으로 하면 pred값이 소수점 6자리까지 나오는게 맞나요
0
49
2
3번문제 등분산 가정
0
47
2
작업형3 target 형 변환 질문
0
34
2
[작업형1] 연습문제 섹션1 ~ 10 의 section4
0
36
3
원핫인코딩과 레이블 인코딩에서 concat
0
58
2
제2유형 질문입니다.
0
46
2
C()
0
44
2
작업형 2에서 strafity 적용 유무
0
51
2
수강 기간 연장 가능 여부 문의드립니다.
0
60
1
ols
0
43
2
2유형 작성관련 질문(일반 심화)
0
39
2
2유형 작성관련 질문
0
41
2
2유형 object컬럼 개수 다르면
0
48
2
코딩팡질문이요ㅠㅠ
0
45
2
관찰값과 기대값의 개념이 헷갈립니다.
0
25
2
작업형2 ID 컬럼 삭제 질문
0
45
2





