r - Create a supervised classifier based on decision trees -


i need in r program language have answer question : ) (a) create supervised classifier based on decision trees. (b) randomly split training , test set determine prediction quality of classifier.

i did code same result categories. there me???

libery(tree) quality<- as.numeric(winequality.red$quality)  range(quality) #8.4  14.9     high = ifelse(winequality.red$quality >= 5, "yes","no") winequality.red2 = data.frame(winequality.red, high) winequality.red2 = winequality.red2[,-12]   #divide data testing , training set.seed(2) train = sample(1:nrow(winequality.red2), nrow(winequality.red2)/2) # half testing , halof training test = -train training_data = winequality.red2[train, ] testing_data = winequality.red2[test, ] testing_test = high[test]  tree_model = tree(test~., training_data) plot(tree_model) text(tree_model, pretty= 0 )  tree_pred = predict(tree_model, testing_data) mean(tree_pred !=testing_data) 

i found rpart better tree. cross validation internally if meant. sure use rpart.plot::prp plot them nicely. there enough documentation on packages here.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -