새소식

반응형
AI/ERROR LOG

DataConversionWarning: A column-vector y was passed when a 1d array was expected.

  • -
반응형

DataConversionWarning


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().

 

def fit_clasifiers(gs_clfs, X, y):
    for clf in gs_clfs:
        print(X.shape)
        clf.fit(X, y)
#before
#fit_clasifiers(gs_clfs, X_train, y_train)

#after
fit_clasifiers(gs_clfs, X_train, y_train.values.ravel())

show_gridsearch_result(gs_clfs)

 

fit_clasifiers 함수에 인자로 y_train에서  y_train.values.ravel()으로 바꾸어 주면 해결됩니다.

 

 

반응형
반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.