(model_param: BoostingTreeModelParam,
               model_meta: BoostingTreeModelMeta,
               load_feature_importance=True)
return result
Transform sbt model to lgb model
Transform sbt model to lgb model
Transform sbt model to lgb model
def sbt_to_lgb(model_param: BoostingTreeModelParam,
               model_meta: BoostingTreeModelMeta,
               load_feature_importance=True):

    """
    Transform sbt model to lgb model
    """

    result = ''
    # parse header
    header_str = parse_header(model_param, model_meta)
    zero_as_missing = model_meta.tree_meta.zero_as_missing
    learning_rate = model_meta.learning_rate
    tree_str_list = []

    # parse tree
    for idx, param in enumerate(model_param.trees_):

        if idx == 0 and model_meta.task_type == consts.REGRESSION:  # regression task has init score
            init_score = model_param.init_score[0]
        else:
            init_score = 0
        tree_str_list.append(parse_a_tree(param, idx, zero_as_missing, learning_rate, init_score))

    # add header and tree str to result
    result += header_str + '\n'
    for s in tree_str_list:
        result += s
        result += SPLIT
    result += END_OF_TREE

    # handle feature importance
    if load_feature_importance:
        feat_importance_str = parse_feature_importance(model_param)
        result += SPLIT+feat_importance_str

    # parameters
    para_str = parse_parameter(model_param, model_meta)
    result += '\n'+para_str+'\n'+END_OF_PARA+'\n'
    result += '\npandas_categorical:[]\n'

    return result
def sbt_to_lgb ( model_param : BoostingTreeModelParam , model_meta : BoostingTreeModelMeta , load_feature_importance = True ) : result = '' # parse header header_str = parse_header ( model_param , model_meta ) zero_as_missing = model_meta . tree_meta . zero_as_missing learning_rate = model_meta . learning_rate tree_str_list = [ ] # parse tree for idx , param in enumerate ( model_param . trees_ ) : if idx == 0 and model_meta . task_type == consts . REGRESSION : # regression task has init score init_score = model_param . init_score [ 0 ] else : init_score = 0 tree_str_list . append ( parse_a_tree ( param , idx , zero_as_missing , learning_rate , init_score ) ) # add header and tree str to result result += header_str + '\n' for s in tree_str_list : result += s result += SPLIT result += END_OF_TREE # handle feature importance if load_feature_importance : feat_importance_str = parse_feature_importance ( model_param ) result += SPLIT + feat_importance_str # parameters para_str = parse_parameter ( model_param , model_meta ) result += '\n' + para_str + '\n' + END_OF_PARA + '\n' result += '\npandas_categorical:[]\n' return result