204.3.8 Practice : Validating the Tree

Finding the tree accuracy.

Link to the previous post :


In the last post we built a decision tree and after plotting we explored the major characteristics of the tree.

In this post we will practice how to validate the tree.

Tree Validation

  • Find the accuracy of the classification for the tree model
#Tree Validation
predict1 = clf.predict(X)
from sklearn.metrics import confusion_matrix ###for using confusion matrix###
cm = confusion_matrix(y, predict1)
print (cm)
[[6370   38]
 [ 648 4749]]
total = sum(sum(cm))
#####from confusion matrix calculate accuracy
accuracy = (cm[0,0]+cm[1,1])/total
  • We can also use the .score() function to predict the accuracy in python from sklearn library.
  • However, confusion matrix allows us to see the wrong classifications too that gives an intutive understanding.

The next post is about the problem of overfitting the decision tree.
Link to the next post :

0 responses on "204.3.8 Practice : Validating the Tree"

Leave a Message

Blog Posts

Hurry up!!!

"use coupon code for FLAT 30% discount"  datascientistoffer        ___________________________________      Subscribe to our youtube channel. Get access to video tutorials.                

Contact Us

Statinfer Software Solutions#647 2nd floor 1st Main, Indira Nagar 1st Stage, 100 feet road,Indranagar Bangalore,Karnataka, Pin code:-560038 Landmarks: Opp. Namma Metro Pillar 48.

Connect with us

linkin fn twitter g

How to become a Data Scientist.?