华为云AI开发平台ModelArts梯度提升树回归_云淘科技
概述
“梯度提升树回归”节点用于生成回归模型,是一种基于决策树的迭代回归算法。该算法采用迭代的思想不断地构建决策树模型,每棵树都是通过梯度优化损失函数而构建,从而达到从基准值到目标值的逼近。算法思想可简单理解成:后一次模型都是针对前一次模型预测出错的情况进行修正,模型随着迭代不断地改进,从而获得比较好的预测效果。
梯度提升树回归的损失函数为均方差损失函数,如下所示:
其中,N 表示样本数量,xi 表示样本i 的特征,yi 表示样本i 的标签,F(xi) 表示样本i 预测的标签。
输入
参数 |
子参数 |
参数说明 |
---|---|---|
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 |
loss_type |
– |
损失函数类型,支持squared、absolute,默认为”squared” |
max_iter |
– |
最大迭代次数,默认为20 |
step_size |
– |
步长,默认为0.1 |
样例
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": "target label column"} "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": ""} "subsampling_rate": 1.0, # @param {"label": "subsampling_rate", "type": "number", "required": "true", "range": "(0.0,1.0]", "helpTip": ""} "loss_type": "squared", # @param {"label": "loss_type", "type": "enum", "required": "true", "options": "squared,absolute", "helpTip": ""} "max_iter": 20, # @param {"label": "max_iter", "type": "integer", "required": "true", "range": "(0,2147483647]", "helpTip": ""} "step_size": 0.1, # @param {"label": "step_size", "type": "number", "required": "true", "range": "(0.0,none)", "helpTip": ""} "impurity": "variance" } gbt_regressor____id___ = MLSGBTRegression(**params) gbt_regressor____id___.run() # @output {"label":"pipeline_model","name":"gbt_regressor____id___.get_outputs()['output_port_1']","type":"PipelineModel"}
父主题: 回归
同意关联代理商云淘科技,购买华为云产品更优惠(QQ 78315851)
内容没看懂? 不太想学习?想快速解决? 有偿解决: 联系专家