- Create an object of LGBMModel using 'td_lightgbm'.
>>> obj_skl_m = td_lightgbm.LGBMModel(num_leaves=15, objective="binary", n_estimators=5)
- Train the model.
>>> obj_skl_m.fit(df_x_classif, df_y_classif, sample_weight=df_train_classif.select("group_column"), partition_columns=["partition_column_1", "partition_column_2"], callbacks=[td_lightgbm.log_evaluation()])partition_column_1 partition_column_2 model 0 1 11 LGBMModel(n_estimators=5, num_leaves=15, objective='binary') 1 0 11 LGBMModel(n_estimators=5, num_leaves=15, objective='binary') 2 1 10 LGBMModel(n_estimators=5, num_leaves=15, objective='binary') 3 0 10 LGBMModel(n_estimators=5, num_leaves=15, objective='binary')
- Deploy multiple models created on multiple partitions.
>>> obj_deploy_skl_m = obj_skl_m.deploy(model_name="lightgbm_sklearn_multi_model")
Model is saved.
- Load the deployed models.
>>> obj_skl_load_model_m = td_lightgbm.load("lightgbm_sklearn_multi_model") - Predict using the loaded models.
>>> obj_skl_load_model_m.predict(df_x_classif, raw_score=True, pred_leaf=True)
partition_column_1 partition_column_2 col1 ... col4 lgbmmodel_predict_1 lgbmmodel_predict_2 ... lgbmmodel_predict_5 1 10 0.05870288650510 ... -1.17785382356 0 0 ... 1 1 10 -1.1615345341513 ... -0.86423207141 3 2 ... 1 1 10 0.78433767392278 ... 0.720943051314 1 1 ... 0 1 10 -0.2464757122084 ... -0.40166606892 8 3 ... 2 1 10 0.23164855319438 ... -1.26023579265 0 0 ... 1 1 10 -0.7267611459507 ... -0.32066543120 7 1 ... 2 0 10 2.08263134345229 ... 1.258519751162 2 2 ... 2 0 10 1.43975694528171 ... 0.656882820481 3 3 ... 3 0 10 -0.6124690179513 ... -0.48785374115 5 3 ... 3 0 10 1.30373436256498 ... 0.933048019921 2 2 ... 2
- Run attributes on the loaded models.
>>> obj_skl_load_model_m.feature_importances_
partition_column_1 partition_column_2 feature_importances_ 0 1 11 [3, 11, 1, 0] 1 0 11 [0, 5, 7, 0] 2 1 10 [2, 7, 2, 2] 3 0 10 [4, 10, 0, 1]