To get predicted values, predict function should be called on the trained Booster object.
>>> opt_pred_s = opt_tr_s.predict(data=df_x_classif, label=df_y_classif, num_iteration=20) >>> opt_pred_s.head(3) col1 col2 col3 col4 label booster_predict_1 0.191240730419773 1.97100133015377 -0.298530178457708 0.890194110648821 1 0.9609170779776948 -1.16999138897268 0.354732459083604 -0.193563184945544 -0.35802804454994 1 0.9358935125840876 1.61885814289279 0.530672471352164 0.101599080962697 0.914093399898154 0 0.4503489139975592
The following examples show how other supported functions can be accessed through Booster object.
model_to_string
>>> str_opt = opt_tr_s.model_to_string(-1) >>> print(str_opt) tree version=v3 num_class=1 num_tree_per_iteration=1 label_index=0 max_feature_idx=3 objective=regression ... ... [gpu_use_dp: 0] [num_gpu: 1] end of parameters pandas_categorical:[] # End of model string output.
model_from_string
>>> opt2 = opt_tr_s.model_from_string(str_opt) >>> opt2 Finished loading model, total used 30 iterations <lightgbm.basic.Booster object at 0x7f5553d235b0>