"GradientBoostedTrees" (机器学习方法)
详细信息与子选项
- 梯度提升是一种用于回归和分类问题的机器学习技术,其产生树的集合形式的预测模型. 树是根据补偿之前树的弱点的目标依次进行培训. 当前的实现在后端使用 LightGBM 框架.
- 可以给出以下选项:
-
MaxTrainingRounds 50 增强的回合数 "BoostingMethod" "Gradient" 使用的方法 "L1Regularization" 0 L1 正则化参数 "L2Regularization" 0 L2 正则化参数 "LeafSize" Automatic 一片叶子上数据样板的最小数 "LearningRate" Automatic 用于梯度下降的学习率 "LeavesNumber" Automatic 一棵树上叶子的最小树 "MaxDepth" 6 每棵树的最大深度 - "BoostingMethod" 的可能设置包括 "Gradient"、"GradientOneSideSampling" 和 "DART"(例如,Dropouts 符合多个加法回归树).
范例
打开所有单元 关闭所有单元基本范例 (2)
p = Predict[{1, 2, 3, 4} -> {.3, .4, .6, 9}, Method -> "GradientBoostedTrees"]Information[p]p[1.3]data = Table[x -> x ^ 2 + RandomVariate[NormalDistribution[0, 5]], {x, RandomReal[{-10, 10}, 200]}];
ListPlot[List@@@data]p = Predict[data, Method -> "GradientBoostedTrees"]Show[Plot[
{p[x],
p[x] + StandardDeviation[p[x, "Distribution"]], p[x] - StandardDeviation[p[x, "Distribution"]]},
{x, -2, 6},
PlotStyle -> {Blue, Gray, Gray},
Filling -> {2 -> {3}},
Exclusions -> False,
PerformanceGoal -> "Speed", PlotLegends -> {"Prediction", "Confidence Interval"}], ListPlot[List@@@data, PlotStyle -> Red, PlotLegends -> {"Data"}]]选项 (8)
"BoostingMethod" (1)
使用不同的 "BoostingMethod" 在 "WineQuality" 培训集上培训两个分类器并比较培训时间:
trainingdata = ExampleData[{"MachineLearning", "WineQuality"}, "TrainingData"];{{t1, c1}, {t2, c2}} = AbsoluteTiming[Classify[trainingdata, Method -> {"GradientBoostedTrees", "BoostingMethod" -> #}]]& /@ {"Gradient", "DART"}testdata = ExampleData[{"MachineLearning", "WineQuality"}, "TestData"];ClassifierMeasurements[#, testdata, "Accuracy"]& /@ {c1, c2}"LeafSize" (2)
Predict[{1, 2, 3, -2, -4, -5} -> {.1, .2, .6, 1.3, 6.7, 8},
Method -> {"GradientBoostedTrees", "LeafSize" -> 1}]通过改变 "LeafSize" 值培训 "Titanic"数据集上的两个分类器:
trainingset = ExampleData[{"MachineLearning", "Titanic"}, "TrainingData"];c3 = Classify[trainingset, Method -> {"GradientBoostedTrees", "LeafSize" -> 3}]c400 = Classify[trainingset, Method -> {"GradientBoostedTrees", "LeafSize" -> 400}]testset = ExampleData[{"MachineLearning", "Titanic"}, "TestData"];ClassifierMeasurements[#, testset, "Accuracy"]& /@ {c3, c400}"LeavesNumber" (1)
trainingset = Table[x -> Cos[x] + RandomVariate[NormalDistribution[0, .5]], {x, RandomReal[{-20, 20}, 300]}];
ListPlot[List@@@trainingset]p5 = Predict[trainingset, Method -> {"GradientBoostedTrees", "LeavesNumber" -> 5}
]p80 = Predict[trainingset, Method -> {"GradientBoostedTrees", "LeavesNumber" -> 80}
]Show[ListPlot[List@@@trainingset], Plot[{p5[x], p80[x]}, {x, -20, 20}]]"MaxDepth" (2)
c = Classify[{1, 2, 3, 4, 5, 6} -> {1, 1, 3, 3, 1, 3}, Method -> {"GradientBoostedTrees", "MaxDepth" -> 3}]使用 "BostonHomes" 培训集培训具有不同 "MaxDepth" 的两个预测器:
trainingdata = ExampleData[{"MachineLearning", "BostonHomes"}, "TrainingData"];p2 = Predict[trainingdata, Method -> {"GradientBoostedTrees", "MaxDepth" -> 2}
]p20 = Predict[trainingdata, Method -> {"GradientBoostedTrees", "MaxDepth" -> 20}
]testdata = ExampleData[{"MachineLearning", "BostonHomes"}, "TestData"];Grid[{PredictorMeasurements[#, testdata, "ComparisonPlot"]& /@ {p2, p20}}, Frame -> All]MaxTrainingRounds (2)
使用 MaxTrainingRounds 选项培训分类器:
c = Classify[{1, 2, 3, 4, 5, 6} -> {1, 1, 3, 3, 1, 3}, Method -> {"GradientBoostedTrees", MaxTrainingRounds -> 5}]通过改变 MaxTrainingRounds 的值培训"Mushroom" 数据集上的两个分类器:
trainingset = ExampleData[{"MachineLearning", "Mushroom"}, "TrainingData"];c3 = Classify[trainingset, Method -> {"GradientBoostedTrees", MaxTrainingRounds -> 3}]c10 = Classify[trainingset, Method -> {"GradientBoostedTrees", MaxTrainingRounds -> 10}]testset = ExampleData[{"MachineLearning", "Mushroom"}, "TestData"];ClassifierMeasurements[c3, testset, "Accuracy"]ClassifierMeasurements[c10, testset, "Accuracy"]