Я пытаюсь обучить LightGBM с помощью gridsearch, я получаю следующую ошибку при попытке обучить модель.
ValueError: For early stopping, at least one dataset and eval metric is required for evaluation
Я предоставил набор данных проверки и метрику оценки c. Не знаю, почему до сих пор возникает эта проблема. Вот мой код.
train_data = rtotal[rtotal['train_Y'] == 1]
test_data = rtotal[rtotal['train_Y'] == 0]
trainData, validData = train_test_split(train_data, test_size=0.007, random_state = 123)
#train data prep
X_train = trainData.iloc[:,2:71]
y_train = trainData.loc[:,['a_class']]
#validation data prep
X_valid = validData.iloc[:,2:71]
y_valid = validData.loc[:,['a_class']]
#X_test
X_test = test_data.iloc[:,2:71]
import lightgbm as lgb
from sklearn.model_selection import GridSearchCV
gridParams = {
'learning_rate': [0.005],
'n_estimators': [40],
'num_leaves': [16,32, 64],
'objective' : ['multiclass'],
'random_state' : [501],
'num_boost_round' : [3000],
'colsample_bytree' : [0.65, 0.66],
'subsample' : [0.7,0.75],
'reg_alpha' : [1,1.2],
'reg_lambda' : [1,1.2,1.4],
}
lgb_estimator = lgb.LGBMClassifier(boosting_type = 'gbdt',
n_estimators=500,
objective = 'multiclass',
learning_rate = 0.05, num_leaves = 64,
eval_metric = 'multi_logloss',
verbose_eval=20,
eval_set = [X_valid, y_valid],
early_stopping_rounds=100)
g_lgbm = GridSearchCV(estimator=lgb_estimator, param_grid=gridParams, n_jobs = 3, cv= 3)
lgb_model = g_lgbm.fit(X=X_train, y=y_train)