python sklearn error ValueError: Classification metrics can't handle a mix of multiclass-multioutput and binary targets

hyereen·2021년 12월 2일
0

env: python 3.9, scikit-learn 0.24.2

# RF
from sklearn.ensemble import RandomForestClassifier
 
model = RandomForestClassifier(max_depth=10, n_estimators=100)
model.fit(x_train, y_train['Reached.on.Time_Y.N'])
print('RF score: ', model.score(x_train,y_train))

ValueError: Classification metrics can't handle a mix of multiclass-multioutput and binary targets

구름 IDE에서 코딩할때도 아마 비슷한 이유로, 에러가 난다.

> /goorm/Main.out:68: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples,), for example using ravel().
  model.fit(x_train, y_train)

  • 해결방법: model.score의 파라미터와 fit의 파라미터의 y_train 셋의 컬럼명을 정확히 입력해준다.
# RF
from sklearn.ensemble import RandomForestClassifier
 
model = RandomForestClassifier(max_depth=10, n_estimators=100)
model.fit(x_train, y_train['Reached.on.Time_Y.N'])
print('RF score: ', model.score(x_train,y_train['Reached.on.Time_Y.N']))

사유는 정확히 모르겠으나 이렇게 하니까 되었다..(?)

profile
안녕하세요. 피드백은 언제나 감사합니다.

0개의 댓글