r - How can I access Classification Decision Tree result and confusion matrix result? -
this general iris modeling code , result:
general iris modeling code , result: > library(party) > library(rpart) > library(tree) > library(caret) > train = sample(1:nrow(iris),nrow(iris)* 0.7) > training_set = iris[train,] > test_set = iris[-train,] > iris_ctree = ctree(species~., data = training_set) > iris_ctree conditional inference tree 4 terminal nodes response: species inputs: sepal.length, sepal.width, petal.length, petal.width number of observations: 105 1) petal.length <= 1.9; criterion = 1, statistic = 97.056 2)* weights = 30 1) petal.length > 1.9 3) petal.width <= 1.7; criterion = 1, statistic = 48.636 4) petal.length <= 4.7; criterion = 0.998, statistic = 12.282 5)* weights = 36 4) petal.length > 4.7 6)* weights = 7 3) petal.width > 1.7 7)* weights = 32 > plot(iris_ctree) > pred = predict(iris_ctree, test_set) > confusionmatrix(pred, test_set$species) confusion matrix , statistics reference prediction setosa versicolor setosa 20 0 versicolor 0 10 virginica 0 0 reference prediction virginica setosa 0 versicolor 1 virginica 14 overall statistics accuracy : 95% ci : no information rate : p-value [acc > nir] : kappa : mcnemar's test p-value : 0.9778 (0.8823, 0.9994) 0.4444 8.12e-15 0.9655 na statistics class: class: setosa sensitivity 1.0000 specificity 1.0000 pos pred value 1.0000 neg pred value 1.0000 prevalence 0.4444 detection rate 0.4444 detection prevalence 0.4444 balanced accuracy 1.0000 class: versicolor sensitivity 1.0000 specificity 0.9714 pos pred value 0.9091 neg pred value 1.0000 prevalence 0.2222 detection rate 0.2222 detection prevalence 0.2444 balanced accuracy 0.9857 class: virginica sensitivity 0.9333 specificity 1.0000 pos pred value 1.0000 neg pred value 0.9677 prevalence 0.3333 detection rate 0.3111 detection prevalence 0.3111 balanced accuracy 0.9667
i want know how access specific node values of 'ctree'. example, approach value of '7', lowest branch.
and want know how approach value of confusion matrix. example, approach accuracy value.
the reason question have model various data in database r , result. appreciate if give me hint.
i found answer. can reference contents.
@extract data ctree
http://rpubs.com/kkweon/294613
how extract tree structure ctree function?
@extract data confusion matrix
https://artax.karlin.mff.cuni.cz/r-help/library/caret/html/confusionmatrix.html
Comments
Post a Comment