Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
rpart决策树模型中的精确概率预测_R - Fatal编程技术网

rpart决策树模型中的精确概率预测

rpart决策树模型中的精确概率预测,r,R,在rpart决策树模型中,如何计算96%或43%的准确概率,而不是0或1。 我试过了 预测(模型、数据,type=“prob”) 但是在创建rpart对象的过程中,它会预测0或1,您必须在参数中指定method=“class”,以确保分类。一旦你用type=“prob”@Nazia Afreen做了预测,你的预测方法就会给出概率-下面是R脚本,希望这会有所帮助 library(rpart) model <- rpart(dependent_class_variable ~ independ

在rpart决策树模型中,如何计算96%或43%的准确概率,而不是0或1。 我试过了 预测(模型、数据,type=“prob”)
但是在创建
rpart
对象的过程中,它会预测0或1,您必须在参数中指定
method=“class”
,以确保分类。一旦你用
type=“prob”

@Nazia Afreen做了预测,你的预测方法就会给出概率-下面是R脚本,希望这会有所帮助

library(rpart)
model <- rpart(dependent_class_variable ~ independent var1 + var 2 + .., data = "your train data", method = "class")

## to get the probabilities of each record
probilities_ <- predict(model, "your test data without quotes", type = "prob")

## it will yield two probabilities, probability of getting class 1, and 
## probability of getting class 2, if you have two class. Sum of both = 1##
库(rpart)

模型a可能会有所帮助。默认的rpart预测是分类概率。我已经尝试过,它给我的概率是0或1。我试图做的是找到实际的概率,如.97或。80@NaziaAfreen也许你的数据实际产生的结果是0或1作为概率,也就是说,你有一个完美的适合,没有误报的机会。如果您正确地执行了上述步骤,那么您应该得到正确的概率。