compare actual values vs predicted values in decision tree

0 votes
How to compare the accuracy of actual values wrt predicted values in R after decision prediction?
Aug 25, 2019 in Data Analytics by anonymous
2,664 views

1 answer to this question.

0 votes

You can compare test data using table() to get a confusion matrix.

1. Create your decision tree.

decision_tree = rpart(predicting value~.,train data)

2. Use the tree to predict for test data.

predicted_table = predict(decision_tree, test data, type = "class")

3. Now use table(predicting variable,predicted model). 

table(predicting variable, predicted_table)

The table gives a confusion matrix like below. It displays the number of records with a true positive, false positive. true negative, false negative count. The row and column can be Yes/No or True/False.

Yes/True No/False
Yes/True
No/False

4. Calculate accuracy as count in [Yes,Yes] + [No,No] / [count of all cells]).

answered Aug 25, 2019 by Cherukuri
• 33,030 points

Related Questions In Data Analytics

+1 vote
2 answers

Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE ...READ MORE

answered Aug 14, 2019 in Data Analytics by anonymous
1,650 views
0 votes
2 answers

In data frame how to spilt strings into values?

You can do this using dplyr and ...READ MORE

answered Dec 5, 2018 in Data Analytics by Kalgi
• 52,360 points
792 views
0 votes
2 answers

How to count unique values in R?

You can try this way, as.data.frame(v) %>% count(v) READ MORE

answered Aug 8, 2019 in Data Analytics by anonymous
6,288 views
0 votes
1 answer

How to replace NA values in a dataframe with Zero's ?

It is simple and easy: df1<-as.data.frame(matrix(sample(c(NA, 1:10), 100, ...READ MORE

answered Apr 10, 2018 in Data Analytics by CodingByHeart77
• 3,740 points
1,838 views
0 votes
1 answer

Use different distance formula other than euclidean distance in k means

K-means is based on variance minimization. The sum-of-variance formula ...READ MORE

answered Jun 21, 2018 in Data Analytics by Sahiti
• 6,370 points
1,410 views
+1 vote
1 answer

How to handle Nominal Data?

Nominal data is basically data which can ...READ MORE

answered Jul 24, 2018 in Data Analytics by Abhi
• 3,720 points
473 views
+2 votes
2 answers

How to handle outliers

There are multiple ways to handle outliers ...READ MORE

answered Jul 24, 2018 in Data Analytics by Abhi
• 3,720 points
723 views
+1 vote
2 answers

How to count the number of elements with the values in a vector?

Use dplyr function group_by(). > n = as.data.frame(num) > ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
4,588 views
0 votes
2 answers

How to remove rows with missing values (NAs) in a data frame?

Hi, The below code returns rows without ...READ MORE

answered Aug 20, 2019 in Data Analytics by anonymous
• 33,030 points
14,439 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP