|
| __init__ (self, params=None, train_set=None, model_file=None, silent=False) |
|
| __del__ (self) |
|
| __copy__ (self) |
|
| __deepcopy__ (self, _) |
|
| __getstate__ (self) |
|
| __setstate__ (self, state) |
|
| free_dataset (self) |
|
| set_network (self, machines, local_listen_port=12400, listen_time_out=120, num_machines=1) |
|
| free_network (self) |
|
| set_train_data_name (self, name) |
|
| add_valid (self, data, name) |
|
| reset_parameter (self, params) |
|
| update (self, train_set=None, fobj=None) |
|
| rollback_one_iter (self) |
|
| current_iteration (self) |
|
| num_model_per_iteration (self) |
|
| num_trees (self) |
|
| eval (self, data, name, feval=None) |
|
| eval_train (self, feval=None) |
|
| eval_valid (self, feval=None) |
|
| save_model (self, filename, num_iteration=None, start_iteration=0) |
|
| shuffle_models (self, start_iteration=0, end_iteration=-1) |
|
| model_from_string (self, model_str, verbose=True) |
|
| model_to_string (self, num_iteration=None, start_iteration=0) |
|
| dump_model (self, num_iteration=None, start_iteration=0) |
|
| predict (self, data, num_iteration=None, raw_score=False, pred_leaf=False, pred_contrib=False, data_has_header=False, is_reshape=True, **kwargs) |
|
| refit (self, data, label, decay_rate=0.9, **kwargs) |
|
| get_leaf_output (self, tree_id, leaf_id) |
|
| num_feature (self) |
|
| feature_name (self) |
|
| feature_importance (self, importance_type='split', iteration=None) |
|
| attr (self, key) |
|
| set_attr (self, **kwargs) |
|
lightgbm.basic.Booster.dump_model |
( |
|
self, |
|
|
|
num_iteration = None , |
|
|
|
start_iteration = 0 |
|
) |
| |
Dump Booster to JSON format.
Parameters
----------
num_iteration : int or None, optional (default=None)
Index of the iteration that should be dumped.
If None, if the best iteration exists, it is dumped; otherwise, all iterations are dumped.
If <= 0, all iterations are dumped.
start_iteration : int, optional (default=0)
Start index of the iteration that should be dumped.
Returns
-------
json_repr : dict
JSON format of Booster.
lightgbm.basic.Booster.eval |
( |
|
self, |
|
|
|
data, |
|
|
|
name, |
|
|
|
feval = None |
|
) |
| |
Evaluate for data.
Parameters
----------
data : Dataset
Data for the evaluating.
name : string
Name of the data.
feval : callable or None, optional (default=None)
Customized evaluation function.
Should accept two parameters: preds, train_data,
and return (eval_name, eval_result, is_higher_better) or list of such tuples.
For multi-class task, the preds is group by class_id first, then group by row_id.
If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i].
Returns
-------
result : list
List with evaluation results.
lightgbm.basic.Booster.eval_train |
( |
|
self, |
|
|
|
feval = None |
|
) |
| |
Evaluate for training data.
Parameters
----------
feval : callable or None, optional (default=None)
Customized evaluation function.
Should accept two parameters: preds, train_data,
and return (eval_name, eval_result, is_higher_better) or list of such tuples.
For multi-class task, the preds is group by class_id first, then group by row_id.
If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i].
Returns
-------
result : list
List with evaluation results.
lightgbm.basic.Booster.eval_valid |
( |
|
self, |
|
|
|
feval = None |
|
) |
| |
Evaluate for validation data.
Parameters
----------
feval : callable or None, optional (default=None)
Customized evaluation function.
Should accept two parameters: preds, train_data,
and return (eval_name, eval_result, is_higher_better) or list of such tuples.
For multi-class task, the preds is group by class_id first, then group by row_id.
If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i].
Returns
-------
result : list
List with evaluation results.
lightgbm.basic.Booster.feature_importance |
( |
|
self, |
|
|
|
importance_type = 'split' , |
|
|
|
iteration = None |
|
) |
| |
Get feature importances.
Parameters
----------
importance_type : string, optional (default="split")
How the importance is calculated.
If "split", result contains numbers of times the feature is used in a model.
If "gain", result contains total gains of splits which use the feature.
iteration : int or None, optional (default=None)
Limit number of iterations in the feature importance calculation.
If None, if the best iteration exists, it is used; otherwise, all trees are used.
If <= 0, all trees are used (no limits).
Returns
-------
result : numpy array
Array with feature importances.
lightgbm.basic.Booster.model_to_string |
( |
|
self, |
|
|
|
num_iteration = None , |
|
|
|
start_iteration = 0 |
|
) |
| |
Save Booster to string.
Parameters
----------
num_iteration : int or None, optional (default=None)
Index of the iteration that should be saved.
If None, if the best iteration exists, it is saved; otherwise, all iterations are saved.
If <= 0, all iterations are saved.
start_iteration : int, optional (default=0)
Start index of the iteration that should be saved.
Returns
-------
str_repr : string
String representation of Booster.
lightgbm.basic.Booster.predict |
( |
|
self, |
|
|
|
data, |
|
|
|
num_iteration = None , |
|
|
|
raw_score = False , |
|
|
|
pred_leaf = False , |
|
|
|
pred_contrib = False , |
|
|
|
data_has_header = False , |
|
|
|
is_reshape = True , |
|
|
** |
kwargs |
|
) |
| |
Make a prediction.
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable or scipy.sparse
Data source for prediction.
If string, it represents the path to txt file.
num_iteration : int or None, optional (default=None)
Limit number of iterations in the prediction.
If None, if the best iteration exists, it is used; otherwise, all iterations are used.
If <= 0, all iterations are used (no limits).
raw_score : bool, optional (default=False)
Whether to predict raw scores.
pred_leaf : bool, optional (default=False)
Whether to predict leaf index.
pred_contrib : bool, optional (default=False)
Whether to predict feature contributions.
Note
----
If you want to get more explanation for your model's predictions using SHAP values
like SHAP interaction values,
you can install shap package (https://github.com/slundberg/shap).
data_has_header : bool, optional (default=False)
Whether the data has header.
Used only if data is string.
is_reshape : bool, optional (default=True)
If True, result is reshaped to [nrow, ncol].
**kwargs
Other parameters for the prediction.
Returns
-------
result : numpy array
Prediction result.
lightgbm.basic.Booster.refit |
( |
|
self, |
|
|
|
data, |
|
|
|
label, |
|
|
|
decay_rate = 0.9 , |
|
|
** |
kwargs |
|
) |
| |
Refit the existing Booster by new data.
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable or scipy.sparse
Data source for refit.
If string, it represents the path to txt file.
label : list, numpy 1-D array or pandas Series / one-column DataFrame
Label for refit.
decay_rate : float, optional (default=0.9)
Decay rate of refit,
will use ``leaf_output = decay_rate * old_leaf_output + (1.0 - decay_rate) * new_leaf_output`` to refit trees.
**kwargs
Other parameters for refit.
These parameters will be passed to ``predict`` method.
Returns
-------
result : Booster
Refitted Booster.
lightgbm.basic.Booster.save_model |
( |
|
self, |
|
|
|
filename, |
|
|
|
num_iteration = None , |
|
|
|
start_iteration = 0 |
|
) |
| |
Save Booster to file.
Parameters
----------
filename : string
Filename to save Booster.
num_iteration : int or None, optional (default=None)
Index of the iteration that should be saved.
If None, if the best iteration exists, it is saved; otherwise, all iterations are saved.
If <= 0, all iterations are saved.
start_iteration : int, optional (default=0)
Start index of the iteration that should be saved.
Returns
-------
self : Booster
Returns self.
lightgbm.basic.Booster.update |
( |
|
self, |
|
|
|
train_set = None , |
|
|
|
fobj = None |
|
) |
| |
Update Booster for one iteration.
Parameters
----------
train_set : Dataset or None, optional (default=None)
Training data.
If None, last training data is used.
fobj : callable or None, optional (default=None)
Customized objective function.
For multi-class task, the score is group by class_id first, then group by row_id.
If you want to get i-th row score in j-th class, the access way is score[j * num_data + i]
and you should group grad and hess in this way as well.
Returns
-------
is_finished : bool
Whether the update was successfully finished.