해결된 질문
작성
·
1.3K
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
해당 코드로 제출까지는 잘 되고 있습니다.
그러나 정확도 측정 시 오류가 발생하여, 제출에 문제가 있는 것인가 불안하여 오류 현상 문의드립니다..!