Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to calculate accuracy from decision trees?

enter image description here

Hi, I am taking a course on Coursera and came into this question. My answer is 1-(4048+3456)/8124=0.076. However, the answer is 0.067. Anybody can help me to solve this? Thank you!!

like image 598
Chao Li Avatar asked Jan 24 '18 03:01

Chao Li


People also ask

How do you determine the accuracy of a decision tree?

Accuracy: The number of correct predictions made divided by the total number of predictions made. We're going to predict the majority class associated with a particular node as True. i.e. use the larger value attribute from each node.

Why do I get a 100% accuracy decision tree?

You are getting 100% accuracy because you are using a part of training data for testing. At the time of training, decision tree gained the knowledge about that data, and now if you give same data to predict it will give exactly same value. That's why decision tree producing correct results every time.

How do you calculate accuracy prediction?

Accuracy is a metric used in classification problems used to tell the percentage of accurate predictions. We calculate it by dividing the number of correct predictions by the total number of predictions. This formula provides an easy-to-understand definition that assumes a binary classification problem.

How do you check the accuracy of a decision tree Regressor in Python?

Predicting and accuracy check We can check the accuracy of predicted data by using MSE and RMSE metrics. Finally, we'll visualize the original and predicted data in a plot. Running the above code provides a plot that shows the the original and predicted test data.


2 Answers

Accuracy: The number of correct predictions made divided by the total number of predictions made.

We're going to predict the majority class associated with a particular node as True. i.e. use the larger value attribute from each node.

So the accuracy for:

  • Depth 1: (3796 + 3408) / 8124
  • Depth 2: (3760 + 512 + 3408 + 72) / 8124

Depth_2 - Depth_1 = 0.06745

like image 114
patricio Avatar answered Sep 18 '22 10:09

patricio


First We will draw confusion metrics for both cases and then find accuracy.

Confusion metrics:

enter image description here

Accuracy= (TP + TN) / (Total number of observation)

Accuracy calculation:

Depth 1: (3796 + 3408) / 8124

Depth 2: (3760 + 512 + 3408 + 72) / 8124

Depth_2 - Depth_1 = 0.06745
like image 27
Ashish Anand Avatar answered Sep 20 '22 10:09

Ashish Anand