lightgbm.CVBooster — LightGBM 4.6.0.99 documentation (original) (raw)

LightGBM

class lightgbm.CVBooster(model_file=None)[source]

Bases: object

CVBooster in LightGBM.

Auxiliary data structure to hold and redirect all boosters of cv() function. This class has the same methods as Booster class. All method calls, except for the following methods, are actually performed for underlying Boosters and then all returned results are returned in a list.

boosters

The list of underlying fitted models.

Type:

list of Booster

best_iteration

The best iteration of fitted model.

Type:

int

__init__(model_file=None)[source]

Initialize the CVBooster.

Parameters:

model_file (str , pathlib.Path or None , optional ( default=None )) – Path to the CVBooster model file.

Methods

__init__([model_file]) Initialize the CVBooster.
model_from_string(model_str) Load CVBooster from a string.
model_to_string([num_iteration, ...]) Save CVBooster to JSON string.
save_model(filename[, num_iteration, ...]) Save CVBooster to a file as JSON text.

model_from_string(model_str)[source]

Load CVBooster from a string.

Parameters:

model_str (str) – Model will be loaded from this string.

Returns:

self – Loaded CVBooster object.

Return type:

CVBooster

model_to_string(num_iteration=None, start_iteration=0, importance_type='split')[source]

Save CVBooster to JSON string.

Parameters:

Returns:

str_repr – JSON string representation of CVBooster.

Return type:

str

save_model(filename, num_iteration=None, start_iteration=0, importance_type='split')[source]

Save CVBooster to a file as JSON text.

Parameters:

Returns:

self – Returns self.

Return type:

CVBooster