decisiontree.Rd
Decision tree Trains a decision on the given training dataset and uses it to predict classification for test dataset. The resulting accuracy, sensitivity and specificity are returned, as well as a tree summary.
decisiontree(data_train, data_test, includeplot = FALSE, showtree = F)
data_train | Training set: dataframe containing classification column and all other columns features. This is the dataset on which the decision tree model is trained. |
---|---|
data_test | Test set: dataframe containing classification column and all other columns features. This is the dataset on which the decision tree model in tested. |
includeplot | Show performance scatter plot (default:FALSE) |
showtree | Show trained decision tree graphically (default:FALSE) |
List containing performance summary, accessed using training (training accuracy), test (test accuracy), trainsensitivity, testsensitivity, trainspecificity, testspecificity. Also accessed using fit is the trained model produced. This can be used to find the features which appear at each level of the tree.
data_train = data.frame( classification=as.factor(c(1,1,0,0,1,1,0,0,1,1)), A=c(1,1,1,0,0,0,1,1,1,0), B=c(0,1,1,0,1,1,0,1,1,0), C=c(0,0,1,0,0,1,0,0,1,0)) data_test = data.frame( classification=as.factor(c(1,1,0,0,1,1,1,0)), A=c(0,0,0,1,0,0,0,1), B=c(1,1,1,0,0,1,1,1), C=c(0,0,1,1,0,0,1,1)) decisiontree(data_train,data_test)#> $training #> [1] 0.6 #> #> $test #> [1] 0.625 #> #> $testsensitivity #> [1] 0 #> #> $testspecificity #> [1] 0 #> #> $trainsensitivity #> [1] 0 #> #> $trainspecificity #> [1] 0 #> #> $fit #> var n wt dev yval complexity ncompete nsurrogate yval2.V1 yval2.V2 #> 1 <leaf> 10 10 4 2 0 0 0 2.0 4.0 #> yval2.V3 yval2.V4 yval2.V5 yval2.nodeprob #> 1 6.0 0.4 0.6 1.0 #>