XGBoost Exporter Module

def add_segmentation(model, segments_equal_to_estimators, mining_schema_for_1st_segment, out, id)[source]

It returns segmentation for a mining model

Parameters:
  • model – Contains Xgboost model object.
  • segments_equal_to_estimators (List) – Contains List Segements equals to the number of the estimators of the model.
  • mining_schema_for_1st_segment – Contains Mining Schema for the First Segment
  • out – Contains the Output element
  • id (Integer) – Index of the Segements
Returns:

Returns Nyoka’s Segment object

Return type:

segments_equal_to_estimators

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

It creates nodes.

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 a list of well structured node for binary classification/inner segments for multi-class classification
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
Returns:

Nyoka’s Segment object

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 XGBoost 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 XGBoost model object

Return type:

{ dictionary element}

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 Xgboost 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:

Returns Nyoka’s MiningModel object

Return type:

mining_models

def get_multiple_model_method(model)[source]

It returns the type of multiple model method for MiningModels.

Parameters:model – Contains Xgboost 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 Xgboost 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:

Returns Nyoka’s Segmentation object

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 Xgboost 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:

Nyoka’s Segment object

Return type:

segment

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

It returns all the segments of the Xgboost classifier.

Parameters:
  • model – Contains Xgboost 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 Nyoka’s Segment object

Return type:

regrs_models

def get_segments_for_xgbr(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 Xgboost 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:

Nyoka’s Segment object

Return type:

segment

def mining_Field_For_First_Segment(feature_names)[source]

It returns the Mining Schema of the First Segment.

Parameters:feature_names (List) – Contains list of feature/column names.
Returns:Nyoka’s MiningSchema object
Return type:mining_schema_for_1st_segment
def replace_name_with_derivedColumnNames(original_name, derived_col_names)[source]

It replace the default names with the names of the attributes.

Parameters:
  • original_name (List) – The name of the node retrieve from model
  • derived_col_names (List) –
  • name of the derived attributes. (The) –
Returns:

Returns the derived column name/original column name.

Return type:

col_name

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

Exports xgboost model 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_xgboost.pmml’)
  • model_name (string (optional)) – Name of the model
  • description (string (optional)) – Description for the model
Returns:

Return type:

Generates the PMML object and exports it to pmml_f_name