示例#1
0
def get_outer_segmentation(model, derived_col_names, col_names, target_name,
                           mining_imp_val, categoric_values, model_name):
    """
    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
    -------
    segmentation :
        Get the outer most Segmentation of an LGB model

    """

    if 'LGBMRegressor' in str(model.__class__):
        segmentation = get_segments(model, derived_col_names, col_names,
                                    target_name, mining_imp_val,
                                    categoric_values, model_name)
    else:
        segmentation = pml.Segmentation(
            multipleModelMethod=get_multiple_model_method(model),
            Segment=get_segments(model, derived_col_names, col_names,
                                 target_name, mining_imp_val, categoric_values,
                                 model_name))
    return segmentation
示例#2
0
def get_segments_for_lgbr(model, derived_col_names, feature_names, target_name,
                          mining_imp_val, categorical_values):
    """
        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
       -------
       segment :
           Get the Segmentation element which contains inner segments.

       """
    segments = list()
    main_key_value = []
    lgb_dump = model.booster_.dump_model()
    for i in range(len(lgb_dump['tree_info'])):
        tree = lgb_dump['tree_info'][i]['tree_structure']
        main_key_value.append(tree)
    segmentation = pml.Segmentation(
        multipleModelMethod=MULTIPLE_MODEL_METHOD.SUM,
        Segment=generate_Segments_Equal_To_Estimators(main_key_value,
                                                      derived_col_names,
                                                      feature_names))
    return segmentation