322 likes | 4.44k Views
A Confusion Matrix is an excellent metric to describe the performance of a classification model. This video on Confusion Matrix with Machine Learning will help you learn the basics of machine learning and the need for a confusion matrix. You will understand how to create a confusion matrix and how to create a confusion matrix. You will get an idea about the different metrics and perform a demo using logistic regression to find the model's accuracy.<br><br>1. Intro to Machine Learning<br>2. Type of Machine learning<br>3. Need for Confusion Matrix<br>4. What is Confusion Matrix<br>5. Creating a Confusion Matrix<br>6. Comparing Confusion matrix<br>7. 3x3 Confusion Matrix<br><br>About Simplilearn Machine Learning course:<br>A form of artificial intelligence, Machine Learning is revolutionizing the world of computing as well as all peopleu2019s digital interactions. Machine Learning powers such innovative automated technologies as recommendation engines, facial recognition, fraud protection and even self-driving cars.This Machine Learning course prepares engineers, data scientists and other professionals with knowledge and hands-on skills required for certification and job competency in Machine Learning.<br><br>What skills will you learn from this Machine Learning course?<br><br>By the end of this Machine Learning course, you will be able to:<br>1. Master the concepts of supervised, unsupervised and reinforcement learning concepts and modeling.<br>2. Gain practical mastery over principles, algorithms, and applications of Machine Learning through a hands-on approach which includes working on 28 projects and one capstone project.<br>3. Acquire thorough knowledge of the mathematical and heuristic aspects of Machine Learning.<br>4. Understand the concepts and operation of support vector machines, kernel SVM, naive Bayes, decision tree classifier, random forest classifier, logistic regression, K-nearest neighbors, K-means clustering and more.<br>5. Be able to model a wide variety of robust Machine Learning algorithms including deep learning, clustering, and recommendation systems<br><br>ud83dudc49Learn more at: https://bit.ly/3fouyY0
E N D
What’s in it for you? • Intro to Machine Learning • Need for Confusion Matrices • What is a Confusion Matrix? • Creating a Confusion Matrix • Confusion Matrix metrics • Comparing Confusion Matrices • 3 x 3 Confusion Matrix
What is Machine Learning? Machine Learning is a subset of Artificial Intelligence that trains machines with vast volumes of data to think and act like humans, without being explicitly programmed Vast volumes of data Trains the model Perform human like tasks
Confusion Matrix with Machine Learning Click here to watch the video
Type of Machine Learning Machine Learning Unsupervised Learning Reinforcement Learning Supervised Learning Model-Free Classification Regression Dimensionality Reduction Model Clustering
What is Classification? Classification is the process of classifying data into different categories based on some of their common characteristicsExample: A system to classify spam emails Inbox Classifier Spam
What is Classification? Our classification algorithm may wrongly classify some values. Before using our model, we need to find out how accurate it is and what mistakes it is making Inbox Classifier Spam
Need for Confusion Matrices Classification Models have multiple output categories. Most error measures will tell us the total error in our model, but we cannot use it to find out individual instances of errors in our model Total Error Score Input Classifier Error Measure Multiple outputs labels /categories
Need for Confusion Matrices During classification, we also have to overcome the limitations of accuracy. Accuracy can be misleading for classification problems. If there is a significant class imbalance, a model might predict the majority class for all cases and have a high accuracy score Inbox Our model predicted 8/10 instances and will have an accuracy of 80%. But, is it classifying correctly? Classifier Spam
What is a Confusion Matrix? A confusion matrix presents a table layout of the different outcomes of prediction and results of a classification problem and helps visualize its outcomes The confusion matrix helps us identify the correct predictions of a model for different individual classes as well as the errors Actual Predicted
Creating Confusion Matrix A confusion matrix consists of rows that contain the values predicted by the classifier and columns which contain the actual values The actual values of our dataset are along the columns Actual The values predicted by our classifier are along the rows Predicted
Creating Confusion Matrix Consider a Confusion Matrix made from a classifier which classifies people based on whether they speak English or not People who can speak English will be classified as positives Actual Positive Negative Positive People who cannot speak English will be classified as negatives Predicted Negative
Creating Confusion Matrix Consider a Confusion Matrix made from a classifier which classifies people based on whether they speak English or not Actual Positive Negative The number of times our actual positive values are equal to predicted positive values gives us True Positives (TP) True Positive Positive Predicted Negative
Creating Confusion Matrix Consider a Confusion Matrix made from a classifier which classifies people based on whether they speak English or not Actual Positive Negative True Positive Positive The number of times our actual negative values are equal to predicted negative values gives us True Negatives(TN) Predicted Negative True Negative
Creating Confusion Matrix Consider a Confusion Matrix made from a classifier which classifies people based on whether they speak English or not Actual Positive Negative The number of times our model wrongly predicts negative values as positives gives us False Positives (FP) True Positive False Positive Positive Predicted Negative True Negative
Creating Confusion Matrix Consider a Confusion Matrix made from a classifier which classifies people based on whether they speak English or not Actual Positive Negative True Positive False Positive Positive The number of times our model wrongly predicts positive values as negatives gives us False Negatives (FP) Predicted Negative False Negative True Negative
Confusion Matrix Metrics Confusion matrix metrics are performance measures which help us find the accuracy of our classifier. There are four main metrics : • Accuracy • Precision • Recall • F1-Score
Confusion Matrix Metrics Confusion matrix metrics are performance measures which help us find the accuracy of our classifier. There are four main metrics : Accuracy: The accuracy is used to find the portion of correctly classified values. It tells us how often our classifier is right It is the sum of all true values divided by total values
Confusion Matrix Metrics Confusion matrix metrics are performance measures which help us find the accuracy of our classifier. There are four main metrics : Precision : Precision is used to calculate the model’s ability to classify positive values correctly. It answers the question, “When the model predicts a positive value, how often is it right?” It is the true positives divided by total number of predicted positive values
Confusion Matrix Metrics Confusion matrix metrics are performance measures which help us find the accuracy of our classifier. There are four main metrics : Recall : It is used to calculate the model's ability to predict positive values. “How often does the model actually predict the correct positive values?" It is the true positives divided by total number of actual positive values
Confusion Matrix Metrics Confusion matrix metrics are performance measures which help us find the accuracy of our classifier. There are four main metrics : F1-Score: It is the harmonic mean of Recall and Precision. It is useful when you need to take both Precision and Recall into account
Comparison of Confusion Matrix Consider the following two confusion matrix, derived from two different classifier. To figure out which one performs better, we find the confusion matrix metrics for both of them Non English Speaker Non English Speaker English Speaker English Speaker English Speaker English Speaker 90 85 11 15 Non English Speaker Non English Speaker 40 40 19 20
Comparison of Confusion Matrix Non English Speaker Non English Speaker English Speaker English Speaker • Accuracy = (TP + TN) / (TF+TN+FP+FN) • = (90+40)/ (90+40+19+11) = 0.8125 • Precision = TP/(TP+FP) • = 90/(90+ 11) = 0.891 • Recall = TP/(TP+FN) • = 90/ (90 + 19) = 0.8256 • F1-Score = 2* Precision*Recall / ( Precision + Recall) • = 2*0.891*0.8256/ (0.8256+ 0.891) = 0.857 • Accuracy = (TP + TN) / (TF+TN+FP+FN) • = (85+40)/ (85+40+15+20) = 0.781 • Precision = TP/(TP+FP) • = 85/(85+ 15) = 0.85 • Recall = TP/(TP+FN) • = 85/ (85 + 20) = 0.809 • F1-Score = 2* Precision*Recall / ( Precision + Recall) • = 2*0.85*0.809/ (0.85+ 0.809) = 0.828 English Speaker English Speaker 90 85 11 15 Non English Speaker Non English Speaker 40 40 19 20
Comparison of Confusion Matrix From the above calculations we see that our first classifier performed better with a better Accuracy and F1-Score Non English Speaker Non English Speaker English Speaker English Speaker English Speaker English Speaker 90 85 11 15 Non English Speaker Non English Speaker 40 40 19 20 Accuracy = 0.781 F1-Score = 0.828 Accuracy = 0.8125 F1-Score = 0.857
3x3 Confusion Matrix To scale up a confusion matrix, you simply extend the number of rows and columns. The true positives will be along the diagonal. All the other values will be FN or FP English English Hindi Hindi French English English Hindi Hindi French
Join us to learn more! simplilearn.com UNITED STATES Simplilearn Solutions Pvt. Limited 201 Spear Street, Suite 1100 San Francisco, CA 94105 Phone: (415) 741-3319 INDIA Simplilearn Solutions Pvt. Limited #53/1C, 24th Main, 2nd Sector HSR Layout, Bangalore 560102 Phone: +91 8069999471 UNITED STATES Simplilearn Solutions Pvt. Limited 801 Corporate Center Drive, Suite 138 Raleigh, NC 27607 Phone: (919) 205-5565