簡體   English   中英

具有(基於 AUC 的)早停輪次的 LightGBM 二元分類器是以對數損失為目標 function,還是在優化算法中使用 AUC?

[英]Does LightGBM binary classifier with (AUC-based) early-stopping rounds take log loss as objective function, or use AUC in optimization algorithm?

我有一個用於二進制分類任務的 LightGBM 梯度提升 model。 LightGBM 參數說明state 二分類的目標 function 是對數損失(交叉熵)。 因此,我知道這是 function model 在其優化中使用的目標。

但是,我已將 model 設置為在驗證數據的 AUC 在 10 輪后沒有改善時停止訓練。 現在,算法的目標 function 是否已更改為基於 AUC 的目標,還是保持原樣,僅在驗證集上並行計算 AUC 以檢查分數是否在 10 輪后沒有提高?

作為參考,我的代碼如下:

model = lightgbm.LGBMClassifier(n_estimators=500, learning_rate=0.01)
fit_params={"early_stopping_rounds":30,
                "eval_metric" : 'auc',
                "eval_set" : [(X_test,y_test)],
                'eval_names': ['valid'],
                #'callbacks': [lgb.reset_parameter(learning_rate=learning_rate_010_decay_power_099)],
                'verbose': 100,
                'categorical_feature': 'auto'}

params = { 'boosting': ['gbdt'],
        'objective': ['binary'],
        'num_leaves': sp_randint(20, 63), # adjust to inc AUC
        'max_depth': sp_randint(3, 8),
        'min_child_samples': sp_randint(100, 500),
        'min_child_weight': [1e-5, 1e-3, 1e-2, 1e-1, 1, 1e1, 1e2, 1e3, 1e4],
        'subsample': sp_uniform(loc=0.2, scale=0.8),
        'colsample_bytree': sp_uniform(loc=0.4, scale=0.6),
        'reg_alpha': [0, 1e-1, 1, 2, 5, 7, 10, 50, 100],
        'reg_lambda': [0, 1e-1, 1, 5, 10, 20, 50, 100],
        'is_unbalance': ['true'],
        'feature_fraction': np.arange(0.3, 0.6, 0.05), # model trained faster AND prevents overfitting
        'bagging_fraction': np.arange(0.3, 0.6, 0.05), # similar benefits as above
        'bagging_freq': np.arange(10, 30, 5),  # after every 20 iterations, lgb will randomly select 50% of observations and use it for next 20 iterations
        }
RSCV = RandomizedSearchCV(model, params, scoring= 'roc_auc', cv=3, n_iter=10, refit=True, random_state=42, verbose=True)
RSCV.fit(X_train, y_train, **fit_params)

目標仍然是對數損失。

我沒有很好的方法來證明這一點。 但 AUC 不能輕易用作目標 function,因為它只關心預測的順序; 它本身無法將預測推向特定值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM