2
$\begingroup$

Right now,I am working on decision trees on python,how do I know what would be the best pruning criteria based on my data?

$\endgroup$

1 Answer 1

1
$\begingroup$

Experimentally: using cross-validation on a subset of your training data, compute the performance of every option that you want to consider. Then select the best option and train the final model using this option.


// 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)
$\endgroup$
2
  • $\begingroup$ Could you explain with a programmatic example? $\endgroup$
    – Sri Test
    Feb 14, 2020 at 20:09
  • $\begingroup$ @SriTest added pseudo code to answer $\endgroup$
    – Erwan
    Feb 15, 2020 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.