You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run LGBM with early stopping, it gives me the scores corresponding to its best iteration.
When I try to reproduce these scores myself, I get different numbers.
import lightgbm as lgb
from sklearn.datasets import load_breast_cancer
import pandas as pd
from sklearn.metrics import mean_absolute_error
from sklearn.model_selection import KFold
data = load_breast_cancer()
X = pd.DataFrame(data.data)
y = pd.Series(data.target)
lgb_params = {'boosting_type': 'dart', 'random_state': 42}
folds = KFold(5)
for train_idx, val_idx in folds.split(X):
X_train, X_valid = X.iloc[train_idx], X.iloc[val_idx]
y_train, y_valid = y.iloc[train_idx], y.iloc[val_idx]
model = lgb.LGBMRegressor(**lgb_params, n_estimators=10000, n_jobs=-1)
model.fit(X_train, y_train,
eval_set=[(X_valid, y_valid)],
eval_metric='mae', verbose=-1, early_stopping_rounds=200)
y_pred_valid = model.predict(X_valid)
print(mean_absolute_error(y_valid, y_pred_valid))
I was expecting that
valid_0's l1: 0.123608
would match my own calculation from mean_absolute_error, but it doesn't. Indeed, here is the top part of my output:
Training until validation scores don't improve for 200 rounds.
Early stopping, best iteration is:
[631] valid_0's l2: 0.0515033 valid_0's l1: 0.123608
0.16287265537021847
The text was updated successfully, but these errors were encountered:
Environment info
Operating System: Linux 64-bit
CPU/GPU model:
C++/Python/R version: 3.7.3
LightGBM version or commit hash: 2.2.1
Reproducible examples
When I run LGBM with early stopping, it gives me the scores corresponding to its best iteration.
When I try to reproduce these scores myself, I get different numbers.
I was expecting that
would match my own calculation from
mean_absolute_error
, but it doesn't. Indeed, here is the top part of my output:The text was updated successfully, but these errors were encountered: