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 24 in Data Analytics by anonymous
36 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 24 by Cherukuri
• 31,840 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 in Data Analytics by anonymous
101 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 4, 2018 in Data Analytics by Kalgi
• 42,540 points
62 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 in Data Analytics by anonymous
1,758 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,690 points
147 views
0 votes
1 answer

What are the options for deploying models in production with R?

Well, I could say that the answer ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,130 points
305 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 darklord
• 6,170 points
397 views
+1 vote
1 answer

How to handle Nominal Data?

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

answered Jul 23, 2018 in Data Analytics by Anmol
• 3,620 points
42 views
+1 vote
2 answers

How to handle outliers

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

answered Jul 23, 2018 in Data Analytics by Anmol
• 3,620 points
50 views
0 votes
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 in Data Analytics by anonymous
• 31,840 points
131 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 in Data Analytics by anonymous
• 31,840 points
5,676 views