LightGBM Exporter Module

def create_node(obj, main_node, derived_col_names)[source]

It creates nodes for the internal Decision Trees.

Parameters:
  • obj (Json) – Contains nodes in json format.
  • main_node – Contains node build with Nyoka class.
  • derived_col_names (List) – Contains column names after preprocessing.
def generate_Segments_Equal_To_Estimators(val, derived_col_names, col_names)[source]

It returns number of Segments equal to the estimator of the model.

Parameters:
  • val (List) – Contains nodes in json format.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
Returns:

Returns list of segments equal to number of estimator of the model

Return type:

segments_equal_to_estimators

def get_PMML_kwargs(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values, model_name)[source]
It returns all the pmml elements.
Parameters:
  • model – Contains LGB model object.
  • derived_col_names (List) – Contains column names after preprocessing
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the target column .
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
  • model_name (string) – Name of the model
Returns:

algo_kwargs – Get the PMML model argument based on LGB model object

Return type:

Dictionary

def get_ensemble_models(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values, model_name)[source]

It returns the Mining Model element of the model

Parameters:
  • model – Contains LGB model object.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value.
  • categoric_values (tuple) – Contains Categorical attribute names and its values
  • model_name (string) – Name of the model
Returns:

Return type:

Returns the MiningModel for the given LGB model

def get_multiple_model_method(model)[source]

It returns the type of multiple model method for MiningModels.

Parameters:model – Contains LGB model object
Returns:
Return type:The multiple model method for a MiningModel.
def get_outer_segmentation(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values, model_name)[source]

It returns the Segmentation element of the model.

Parameters:
  • model – Contains LGB model object.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
  • model_name (string) – Name of the model
Returns:

Get the outer most Segmentation of an LGB model

Return type:

segmentation

def get_segments(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values, model_name)[source]
It returns the Segment element of the model.
Parameters:
  • model – Contains LGB model object.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) –

    Contains the mining_attributes,mining_strategy, mining_impute_value categoric_values : tuple

    Contains Categorical attribute names and its values
    model_name : string
    Name of the model
Returns:

Get the Segments for the Segmentation element.

Return type:

segment

def get_segments_for_lgbc(model, derived_col_names, feature_names, target_name, mining_imp_val, categoric_values, model_name)[source]

It returns all the segments of the LGB classifier.

Parameters:
  • model – Contains LGB model object.
  • derived_col_names (List) – Contains column names after preprocessing.
  • feature_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
  • model_name (string) – Name of the model
Returns:

Returns all the segments of the LGB model.

Return type:

regrs_models

def get_segments_for_lgbr(model, derived_col_names, feature_names, target_name, mining_imp_val, categorical_values)[source]
It returns all the Segments element of the model
Parameters:
  • model – Contains LGB model object.
  • derived_col_names (List) – Contains column names after preprocessing.
  • feature_names (List) – Contains list of feature/column names.
  • target_name (List) – Name of the Target column.
  • mining_imp_val (tuple) –

    Contains the mining_attributes,mining_strategy, mining_impute_value categoric_values : tuple

    Contains Categorical attribute names and its values
Returns:

Get the Segmentation element which contains inner segments.

Return type:

segment

def lgb_to_pmml(pipeline, col_names, target_name, pmml_f_name='from_lgbm.pmml', model_name=None, description=None)[source]

Exports LGBM pipeline object into pmml

Parameters:
  • pipeline – Contains an instance of Pipeline with preprocessing and final estimator
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the target column.
  • pmml_f_name (String) – Name of the pmml file. (Default=’from_lgbm.pmml’)
  • model_name (string (optional)) – Name of the model
  • description (string (optional)) – Description of the model
Returns:

Return type:

Exports the generated PMML object to pmml_f_name