How to compare the accuracy of actual values wrt predicted values in R after decision prediction? Aug 25, 2019 1,524 views

## 1 answer to this question.

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

`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
• 33,010 points

+1 vote

## 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

## In data frame how to spilt strings into values?

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

## How to count unique values in R?

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

## 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

## 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

+1 vote

## How to handle Nominal Data?

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

## How to handle outliers

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

+1 vote