from xgboost.sklearn import XGBRegressor
from sklearn.model_selection import GridSearchCV
param_grid ={
'n_estimators' :[50,100,200],
'learning_rate':[0.01,0.1,0.3],
'max_depth':[3,5,7],
'subsample':[0.7, 1.0],
'colsample_bytree':[0.7,1.0]
}
model = GridSearchCV(
estimator=XGBRegressor(random_state=111),
param_grid= param_grid,
scoring= 'neg_root_mean_squared_error',
cv = 3
)
model.fit(X_train, y_train)
print(model.best_params_)
/usr/local/lib/python3.10/dist-packages/sklearn/base.py in __sklearn_tags__(self)
611
612 def __sklearn_tags__(self):
--> 613 tags = super().__sklearn_tags__()
614 tags.estimator_type = "regressor"
615 tags.regressor_tags = RegressorTags()
AttributeError: 'super' object has no attribute '__sklearn_tags__'
Colab์ผ๋ก XGBoost์ ๊ทธ๋ฆฌ๋์์น ์ ์ฉํ ์ฝ๋๋ฅผ ์คํํ๋๋ฐ, ์ด๋ฐ ์ค๋ฅ๊ฐ ๋ฐ์ํจ
1. ๋ฌธ์ ์์ธ
: Scikit-learn 1.6๋ฒ์ ์์ tag ์ค์ฌ์ผ๋ก API๋ฅผ ์์ ํด์, ์ด๋ฐ ์ค๋ฅ๊ฐ ๋๋ค๊ณ ํ๋ค
2. ํด๊ฒฐ ๋ฐฉ๋ฒ
: ๊ทธ๋ฅ scikit-learn ๋ฒ์ ์ ๋ฎ์ถ๋ฉด ํด๊ฒฐ๋๋ ๋ฏํจ
(1.5.2 ๋ฒ์ ์ด ์๋๋ ๊ฒฝ์ฐ๋ ์๋ ๊ฒ ๊ฐ์๋ฐ, 1.3.1๋ก ํ์ ๋, ๋๋ ๊ฒฝ์ฐ๋ ์์ผ๋ ํ์ธํด๋ณด๋ฉด ์ข์ ๋ฏ ํฉ๋๋ค !)
!pip uninstall -y scikit-learn
!pip install scikit-learn==1.5.2
** Colab์์๋ ์ ์ฝ๋๋ฅผ ์คํํ ํ, ์ธ์ ์ฌ์์์ ํด์ผ ์๋ฌ๊ฐ ํด๊ฒฐ๋ฉ๋๋ค !!