我正在尝试优化 XGB 回归模型的参数学习率和最大深度:
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import cross_val_score
from xgboost import XGBRegressor
param_grid = [
# trying learning rates from 0.01 to 0.2
{'eta ':[0.01, 0.05, 0.1, 0.2]},
# and max depth from 4 to 10
{'max_depth': [4, 6, 8, 10]}
]
xgb_model = XGBRegressor(random_state = 0)
grid_search = GridSearchCV(xgb_model, param_grid, cv=5,
scoring='neg_root_mean_squared_error',
return_train_score=True)
grid_search.fit(final_OH_X_train_scaled, y_train)
Run Code Online (Sandbox Code Playgroud)
final_OH_X_train_scaled是仅包含数值特征的训练数据集。
y_train是训练标签 - 也是数字。
这是返回错误:
FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will …Run Code Online (Sandbox Code Playgroud) 我在 Conda 环境中使用 Pandas 1.3.2。
在 Jupyter Notebook 上导入 pandas 时:
import pandas as pd
Run Code Online (Sandbox Code Playgroud)
我收到错误:
ImportError: cannot import name 'DtypeArg' from 'pandas._typing' (C:\Users\tone_\anaconda3\envs\spyder\lib\site-packages\pandas\_typing.py)
Run Code Online (Sandbox Code Playgroud)
我见过类似的问题,但到目前为止还没有解决方案。
有人可以帮忙吗?