现在,我正在研究python上的决策树,我怎么知道根据我的数据最好的修剪标准是什么?
我如何知道决策树的最佳修剪标准?
数据挖掘
机器学习
Python
决策树
机器学习模型
2022-02-24 17:23:53
1个回答
实验性:对训练数据的子集使用交叉验证,计算您要考虑的每个选项的性能。然后选择最佳选项并使用此选项训练最终模型。
// different settings for hyper-parameters,
// for instance different pruning criteria:
hpSet = { hp1, hp2, ...}
trainSet, testSet = split(data)
for each hp in hpSet:
// run cross-validation over 'train' using hyper-parameter 'hp'
// and store resulting performance
perf[hp] = runCV(k, trainSet, hp)
bestHP = pick maximum hp in 'perf'
model = train(trainSet, bestHP)
perf = test(model, testSet)
其它你可能感兴趣的问题