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']))
사유는 정확히 모르겠으나 이렇게 하니까 되었다..(?)