xgboost_to_pmml module

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

It returns the First Segments for a binary classifier and returns number of Segments equls to number of values target class for multiclass classifier

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
  • -------
  • segments_equal_to_estimators – Returns list of segments equal to number of estimator of the model
xgboost_to_pmml.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
  • -------
  • segments_equal_to_estimators – Returns list of segments equal to number of estimator of the model
xgboost_to_pmml.generate_main_Key_Value(fetch)[source]
It returns a List where the nodes of the model are in a structured format.
Parameters:
  • fetch (List) – Contains nodes in JSON format
  • Returns
  • -------
  • main_key_value – Returns a list of nodes in a structured format.
xgboost_to_pmml.get_PMML_kwargs(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[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
Returns:

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

Return type:

{ dictionary element}

xgboost_to_pmml.get_ensemble_models(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[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
Returns:

Returns the MiningModel of the respective Xgboost model

Return type:

mining_models

xgboost_to_pmml.get_multiple_model_method(model)[source]

It returns the name of the Multiple Model Chain element of the model.

Parameters:model – Contains Xgboost model object
Returns:
  • modelChain for XGBoost Classifier,
  • sum for XGboost Regressor,
xgboost_to_pmml.get_outer_segmentation(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[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
Returns:

Get the outer most Segmentation of an xgboost model

Return type:

segmentation

xgboost_to_pmml.get_segments(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[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
Returns:

Get the Segments for the Segmentation element.

Return type:

segment

xgboost_to_pmml.get_segments_for_xgbc(model, derived_col_names, feature_names, target_name, mining_imp_val, categoric_values)[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
Returns:

Returns all the segments of the xgboost model.

Return type:

regrs_models

xgboost_to_pmml.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:

Get the Segmentation element which contains inner segments.

Return type:

segment

xgboost_to_pmml.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
  • -------
  • mining_schema_for_1st_segment – Returns the MiningSchema for the main segment.
xgboost_to_pmml.node_generator(dict_var)[source]

This method yields all the nodes in a structured format

Parameters:
  • dict_var (Dictionary) – Contains a dictionary of JSON-format of the nodes.
  • Yield
  • ------- – Yields a list of nodes in a structured format.
xgboost_to_pmml.replace_name_with_derivedColumnNames(original_name, derived_col_names)[source]

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

original_name: List
The name of the node retrieve from model
derived_col_names: List
The name of the derived attributes.
col_name:
Returns the derived column name/original column name.
xgboost_to_pmml.xgboost_to_pmml(pipeline, col_names, target_name, pmml_f_name='from_xgboost.pmml')[source]

Exports xgboost 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_xgboost.pmml’)
Returns:

Return type:

Returns a pmml file