更新时间:2022-11-16 GMT+08:00
分享

随机森林回归

概述

“随机决策森林回归”节点用于产生回归模型。随机决策森林是用随机的方式建立一个森林模型,森林由很多的决策树组成,每棵决策树之间没有关联。当有一个新的样本输入时,该样本取值为所有决策树的预测值的平均值。

随机决策森林回归中的决策树算法是递归地构建决策树的过程,用平方误差最小准则,进行特征选择,生成二叉树。平方误差计算公式如下:

其中 是样本类标的均值,yi 是样本的标签,N 是样本数量。

输入

参数

子参数

参数说明

inputs

dataframe

inputs为字典类型,dataframe为pyspark中的DataFrame类型对象

输出

spark pipeline类型的模型

参数说明

参数

子参数说明

参数说明

b_use_default_encoder

-

是否使用默认编码,默认为True

input_features_str

-

输入的列名以逗号分隔组成的字符串,例如:

"column_a"

"column_a,column_b"

label_col

-

目标列

regressor_feature_vector_col

-

算子输入的特征向量列的列名,默认为"model_features"

max_depth

-

树的最大深度,默认为5

max_bins

-

最大分箱数,默认为32

min_instances_per_node

-

节点分割时,要求子节点必须包含的最少实例数,默认为1

min_info_gain

-

节点是否分割要求的最小信息增益,默认为0.0

subsampling_rate

-

学习每棵决策树用到的训练集的抽样比例,默认为1.0

num_trees

-

树的个数,默认为20

feature_subset_strategy

-

节点分割时考虑用到的特征列的策略,支持auto、all、onethird、sqrt、log2、n,默认为"all"

样例

inputs = {
    "dataframe": None  # @input {"label":"dataframe","type":"DataFrame"}
}
params = {
    "inputs": inputs,
    "b_output_action": True,
    "b_use_default_encoder": True,  # @param {"label": "b_use_default_encoder", "type": "boolean", "required": "true", "helpTip": ""}
    "input_features_str": "",  # @param {"label": "input_features_str", "type": "string", "required": "false", "helpTip": ""}
    "outer_pipeline_stages": None,
    "label_col": "",  # @param {"label": "label_col", "type": "string", "required": "true", "helpTip": ""}
    "regressor_feature_vector_col": "model_features",  # @param {"label": "regressor_feature_vector_col", "type": "string", "required": "true", "helpTip": ""}
    "max_depth": 5,  # @param {"label": "max_depth", "type": "integer", "required": "true", "range": "(0,2147483647]", "helpTip": ""}
    "max_bins": 32,  # @param {"label": "max_bins", "type": "integer", "required": "true", "range": "(0,2147483647]", "helpTip": ""}
    "min_instances_per_node": 1,  # @param {"label": "min_instances_per_node", "type": "integer", "required": "true", "range": "(0,2147483647]", "helpTip": ""}
    "min_info_gain": 0.0,  # @param {"label": "min_info_gain", "type": "number", "required": "true", "range": "[0.0,none)", "helpTip": ""}
    "impurity": "variance",
    "subsampling_rate": 1.0,  # @param {"label": "subsampling_rate", "type": "number", "required": "true", "range": "(0.0,1.0]", "helpTip": ""}
    "num_trees": 20,  # @param {"label": "num_trees", "type": "integer", "required": "true", "range": "(0,2147483647]", "helpTip": ""}
    "feature_subset_strategy": "all"  # @param {"label": "feature_subset_strategy", "type": "enum", "required": "true", "options":"auto,all,onethird,sqrt,log2", "helpTip": ""}
}
rf_regressor____id___ = MLSRandomForestRegression(**params)
rf_regressor____id___.run()
# @output {"label":"pipeline_model","name":"rf_regressor____id___.get_outputs()['output_port_1']","type":"PipelineModel"}

分享:

    相关文档

    相关产品