Callbacks
deepgboost.callbacks.base_callback.TrainingCallback
Abstract base class for DeepGBoost training callbacks.
Subclass this and override any of the four hook methods you need. All methods have safe default implementations (no-op / False).
Source code in src/deepgboost/callbacks/base_callback.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
after_iteration(model, epoch, evals_log)
Called at the end of each boosting layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
DGBFModel
|
The model being trained. |
required |
epoch
|
int
|
Zero-based layer index. |
required |
evals_log
|
dict
|
|
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/deepgboost/callbacks/base_callback.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
after_training(model)
Called once after the layer loop ends (or early-stopping).
Source code in src/deepgboost/callbacks/base_callback.py
36 37 38 39 40 | |
before_iteration(model, epoch, evals_log)
Called at the start of each boosting layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
DGBFModel
|
The model being trained. |
required |
epoch
|
int
|
Zero-based layer index. |
required |
evals_log
|
dict
|
|
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/deepgboost/callbacks/base_callback.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
before_training(model)
Called once before the layer loop begins.
Source code in src/deepgboost/callbacks/base_callback.py
30 31 32 33 34 | |
deepgboost.callbacks.early_stopping_callback.EarlyStoppingCallback
Bases: TrainingCallback
Stop training when a monitored metric stops improving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
patience
|
int
|
Number of layers with no improvement before stopping. |
10
|
metric
|
str
|
Metric key to monitor inside |
'train_loss'
|
data
|
str or None
|
Name of the eval dataset to monitor. If |
None
|
restore_best
|
bool
|
If |
True
|
min_delta
|
float
|
Minimum change to qualify as an improvement. |
1e-06
|
Source code in src/deepgboost/callbacks/early_stopping_callback.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
deepgboost.callbacks.evaluation_monitor_callback.EvaluationMonitorCallback
Bases: TrainingCallback
Print evaluation metrics to stdout after each layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period
|
int
|
Print every |
1
|
Source code in src/deepgboost/callbacks/evaluation_monitor_callback.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
deepgboost.callbacks.learning_rate_scheduler_callback.LearningRateSchedulerCallback
Bases: TrainingCallback
Adjust model.learning_rate before each boosting layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule_fn
|
callable
|
A function |
required |
Examples:
>>> scheduler = LearningRateScheduler(lambda epoch: 0.1 * 0.95**epoch)
Source code in src/deepgboost/callbacks/learning_rate_scheduler_callback.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |