해결된 질문
작성
·
451
0
goorm을 써서 코드를 실행해보는데
데이터 분석하는 과정에서 랜덤 포레스트를 쓸 때는 warning 메시지가 하나도 안 나왔는데 한번 XGBoost를 사용하니까 바로
WARNING: ../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
0.9724770642201834
/usr/local/lib/python3.9/dist-packages/xgboost/compat.py:31: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
from pandas import MultiIndex, Int64Index
/usr/local/lib/python3.9/dist-packages/xgboost/sklearn.py:1146: UserWarning: The use of label encoder in XGBClassifier is deprecated and will be removed in a future release. To remove this warning, do the following: 1) Pass option use_label_encoder=False when constructing XGBClassifier object; and 2) Encode your labels (y) as integers starting with 0, i.e. 0, 1, 2, ..., [num_class - 1].
warnings.warn(label_encoder_deprecation_msg, UserWarning)
/usr/local/lib/python3.9/dist-packages/xgboost/data.py:208: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
from pandas import MultiIndex, Int64Index
이런 워닝 코드가 뜹니다. 어떤 것이 문제일까요?
코드는 아래에 있습니다.
import pandas as pd
pd.set_option('display.max_columns',None)
train = pd.read_csv("train.csv")
test = pd.read_csv("test.csv")
# 사용자 코딩
# print(train.head())
# print(train.describe())
from sklearn.model_selection import train_test_split
X_tr,X_val,y_tr,y_val = train_test_split(train.drop('target',axis=1), train['target'],
test_size=0.2, random_state=2022)
from sklearn.ensemble import RandomForestClassifier
rf = RandomForestClassifier(random_state=2022, max_depth=5, n_estimators=400)
rf.fit(X_tr,y_tr)
pred = rf.predict(X_val)
from xgboost import XGBClassifier
xgb = XGBClassifier(random_state=2022, max_depth=5, n_estimators=400, learning_rate=0.01)
xgb.fit(X_tr,y_tr)
pred = xgb.predict(X_val)
from sklearn.metrics import f1_score
print(f1_score(y_val,pred))
답변 1
0
xgb가 예민하게 워닝을 발생하더라고요 !
새소식에 lightGBM 사용 방법 안내와 lightGBM 뽀너스 영상을 추가했습니다.
부스팅계열이면서 xgb보다 속도가 빠른 lightgbm을 추천해요!