Medial Code Documentation
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
lightgbm.callback Namespace Reference

Data Structures

class  EarlyStopException
 

Functions

 _format_eval_result (value, show_stdv=True)
 
 print_evaluation (period=1, show_stdv=True)
 
 record_evaluation (eval_result)
 
 reset_parameter (**kwargs)
 
 early_stopping (stopping_rounds, verbose=True)
 

Variables

 CallbackEnv
 

Detailed Description

Callbacks library.

Function Documentation

◆ _format_eval_result()

lightgbm.callback._format_eval_result (   value,
  show_stdv = True 
)
protected
Format metric string.

◆ early_stopping()

lightgbm.callback.early_stopping (   stopping_rounds,
  verbose = True 
)
Create a callback that activates early stopping.

Note
----
Activates early stopping.
The model will train until the validation score stops improving.
Validation score needs to improve at least every ``early_stopping_rounds`` round(s)
to continue training.
Requires at least one validation data and one metric.
If there's more than one, will check all of them. But the training data is ignored anyway.

Parameters
----------
stopping_rounds : int
   The possible number of rounds without the trend occurrence.
verbose : bool, optional (default=True)
    Whether to print message with early stopping information.

Returns
-------
callback : function
    The callback that activates early stopping.

◆ print_evaluation()

lightgbm.callback.print_evaluation (   period = 1,
  show_stdv = True 
)
Create a callback that prints the evaluation results.

Parameters
----------
period : int, optional (default=1)
    The period to print the evaluation results.
show_stdv : bool, optional (default=True)
    Whether to show stdv (if provided).

Returns
-------
callback : function
    The callback that prints the evaluation results every ``period`` iteration(s).

◆ record_evaluation()

lightgbm.callback.record_evaluation (   eval_result)
Create a callback that records the evaluation history into ``eval_result``.

Parameters
----------
eval_result : dict
   A dictionary to store the evaluation results.

Returns
-------
callback : function
    The callback that records the evaluation history into the passed dictionary.

◆ reset_parameter()

lightgbm.callback.reset_parameter ( **  kwargs)
Create a callback that resets the parameter after the first iteration.

Note
----
The initial parameter will still take in-effect on first iteration.

Parameters
----------
**kwargs : value should be list or function
    List of parameters for each boosting round
    or a customized function that calculates the parameter in terms of
    current number of round (e.g. yields learning rate decay).
    If list lst, parameter = lst[current_round].
    If function func, parameter = func(current_round).

Returns
-------
callback : function
    The callback that resets the parameter after the first iteration.

Variable Documentation

◆ CallbackEnv

lightgbm.callback.CallbackEnv
Initial value:
1= collections.namedtuple(
2 "LightGBMCallbackEnv",
3 ["model",
4 "params",
5 "iteration",
6 "begin_iteration",
7 "end_iteration",
8 "evaluation_result_list"])