Skip to content

[python-package] custom early stopping by constraint #6935

Open
@sluo1250

Description

@sluo1250

Hi there,

I'm trying to do early stopping based on a constraint. Specifically, I have a custom metric that I would like to keep under a threshold, but not trying to optimize. For example, I'm trying to do lgbm.train() with early stopping based on two metrics, one inherited from objective which is 'quantile', and the other one is my custom metric and I would like to keep quantile going less while keep my custom metric under 0.

I don't see any functionality/parameters to do described above, so I was trying to do a hack that if the calculated metric is less than 0, make it become 0, thus it satisifies "require the early stopping metric to improve by at least this delta to be considered an improvement", as described here early_stopping_min_delta. From my understand of early_stopping_min_delta, it should not stop when the score is the same across iterations when it is set to 0, but from what I'm observing it will stop (see below example when early_stopping_round=20), so I guess it has to improve.

Is there any way to directly do early stopping based on a threshold? If not what would be a suggested way to get around it?

Thanks in advance.

[1]     valid_0's quantile: 3.3088      valid_0's MIM: 0
[2]     valid_0's quantile: 3.29459     valid_0's MIM: 0
[3]     valid_0's quantile: 3.28052     valid_0's MIM: 0
[4]     valid_0's quantile: 3.26736     valid_0's MIM: 0
[5]     valid_0's quantile: 3.25439     valid_0's MIM: 0
[6]     valid_0's quantile: 3.24121     valid_0's MIM: 0
[7]     valid_0's quantile: 3.22818     valid_0's MIM: 0
[8]     valid_0's quantile: 3.21452     valid_0's MIM: 0
[9]     valid_0's quantile: 3.20201     valid_0's MIM: 0
[10]    valid_0's quantile: 3.19017     valid_0's MIM: 0
[11]    valid_0's quantile: 3.17816     valid_0's MIM: 0
[12]    valid_0's quantile: 3.16569     valid_0's MIM: 0
[13]    valid_0's quantile: 3.15328     valid_0's MIM: 0
[14]    valid_0's quantile: 3.14131     valid_0's MIM: 0
[15]    valid_0's quantile: 3.12919     valid_0's MIM: 0
[16]    valid_0's quantile: 3.1168      valid_0's MIM: 0
[17]    valid_0's quantile: 3.1045      valid_0's MIM: 0
[18]    valid_0's quantile: 3.09259     valid_0's MIM: 0
[19]    valid_0's quantile: 3.08005     valid_0's MIM: 0
[20]    valid_0's quantile: 3.06624     valid_0's MIM: 0
[21]    valid_0's quantile: 3.05351     valid_0's MIM: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions