본문 바로가기
프로그래밍/오류

xgboost 오류 해결 방법 FutureWarning: is_sparse is deprecated and will be removed in a future version. Check `isinstance(dtype, pd.SparseDtype)` instead. if is_sparse(data):

by 조이써니 2023. 9. 29.
반응형

FutureWarning: is_sparse is deprecated and will be removed in a future version. Check `isinstance(dtype, pd.SparseDtype)` instead. if is_sparse(data):

 

xgboost 모델을 돌리다 보면 위와 같은 오류가 뜹니다 해결방법에 대해 알아보겠습니다.

원인 : xgboost 라이브러리에서 판다스의 is_categorical_dtype 함수를 사용할 때 발생합니다. 판다스에서 해당 함수를 미래에 제거할 예정이기 때문에 경고메시지가 뜨는 것입니다.

 

1. xgboost 최신버전 업데이트

pip install xgboost --upgrade

터미널에 xgboost를 최신버전으로 업데이트해줍니다. 해당 방법이 안되면 2번 방법을 시도해 볼 수 있습니다.

 

2. 경고 무시

import warnings
warnings.filterwarnings(action='ignore', category=FutureWarning)

 

FutureWarning 경고 메세지를 무시하는 코드입니다. 경고를 무시해도 코드는 잘 작동하므로 해당 방법을 사용해도 됩니다.

반응형

댓글