• No products in the cart.

204.3.8 Practice : Validating the Tree

Finding the tree accuracy.

Link to the previous post : https://course.dvanalyticsmds.com/204-3-7-building-a-decision-tree-in-python/

 

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
accuracy
0.94188903007200342
  • 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.
clf.score(X,y)
0.94188903007200342

The next post is about the problem of overfitting the decision tree.
Link to the next post : https://course.dvanalyticsmds.com/204-3-9-the-problem-of-overfitting-the-decision-tree/

DV Analytics

DV Data & Analytics is a leading data science,  Cyber Security training and consulting firm, led by industry experts. We are aiming to train and prepare resources to acquire the most in-demand data science job opportunities in India and abroad.

Bangalore Center

DV Data & Analytics Bangalore Private Limited
#52, 2nd Floor:
Malleshpalya Maruthinagar Bengaluru.
Bangalore 560075
India
(+91) 9019 030 033 (+91) 8095 881 188
Email: info@dvanalyticsmds.com

Bhubneshwar Center

DV Data & Analytics Private Limited Bhubaneswar
Plot No A/7 :
Adjacent to Maharaja Cine Complex, Bhoinagar, Acharya Vihar
Bhubaneswar 751022
(+91) 8095 881 188 (+91) 8249 430 414
Email: info@dvanalyticsmds.com

top
© 2020. All Rights Reserved.