【发布时间】:2021-05-16 22:16:24
【问题描述】:
我有一个数据集,其目标变量为Target。我将数据集拆分为训练集和测试集,并应用了决策树分类:
library(rpart)
classifier = rpart(formula = Target ~ .,data = training_set)
我想应用网格搜索来找到最佳参数,然后我写:
library(caret)
classifier = train(form = Target ~ ., data = training_set, method = 'ctree')
获得
>classifier
Conditional Inference Tree
8792 samples
8 predictor
2 classes: '0', '1'
No pre-processing
Resampling: Bootstrapped (25 reps)
Summary of sample sizes: 8792, 8792, 8792, 8792, 8792, 8792, ...
Resampling results across tuning parameters:
mincriterion Accuracy Kappa
0.01 0.8881768 0.4373290
0.50 0.8936227 0.4350515
0.99 0.8927400 0.4102918
Accuracy was used to select the optimal model using the largest value.
The final value used for the model was mincriterion = 0.5.
和
>classifier$bestTune
mincriterion
2 0.5
现在如何使用这个值来改进我的模型?
【问题讨论】:
-
您使用
train()来找到最佳超参数。在这种情况下,它是mincriterion。您可以尝试使用 train 中的最终对象进行预测。您所说的改进模型是什么意思?
标签: r classification decision-tree