Tutorial 34- Performance Metrics For Classification Problem In Machine Learning- Part1

Krish Naik
27 Jan 202024:12

Summary

TLDRIn this educational video, the host Krishna introduces key metrics for evaluating classification problems in machine learning. The script covers confusion matrices, accuracy, type 1 and 2 errors, recall, precision, and the F-beta score. It emphasizes the importance of selecting the right metrics for model evaluation, especially in the context of balanced and imbalanced datasets. The video promises a continuation with ROC curves, AUC scores, and PR curves, followed by practical implementation on an imbalanced dataset to demonstrate the impact of different metrics on model accuracy.

Takeaways

  • 📈 The video discusses various metrics for evaluating classification problems in machine learning, emphasizing the importance of selecting the right metrics for model evaluation.
  • 📊 The script introduces the concept of a confusion matrix, explaining its components like true positives, false positives, true negatives, and false negatives, which are crucial for understanding model performance.
  • 🔢 The video explains accuracy as a metric for balanced datasets, where the model's performance is measured by the proportion of correct predictions over the total predictions.
  • ⚖️ It highlights the difference between balanced and imbalanced datasets, noting that accuracy may not be a reliable metric for the latter due to potential bias towards the majority class.
  • 👀 The importance of recall (true positive rate) and precision (positive prediction value) is emphasized for evaluating models on imbalanced datasets, as they focus on reducing type 1 and type 2 errors respectively.
  • 🤖 The script introduces the F-beta score, a metric that combines recall and precision, allowing for the weighting of the importance of false positives versus false negatives through the beta parameter.
  • 📚 The video outlines the use of precision in scenarios where false positives are particularly costly, such as in spam detection, while recall is prioritized in cases like medical diagnosis to avoid missing critical conditions.
  • 🧩 The F-beta score is detailed with its formula and application, showing how it can be adjusted with the beta value to reflect the relative importance of precision and recall in different contexts.
  • 🔍 The video promises to cover additional metrics like Cohen's Kappa, ROC curve, AUC score, and PR curve in the next part of the series, indicating a comprehensive approach to model evaluation.
  • 🛠️ Part three of the video series will include a practical implementation on an imbalanced dataset, demonstrating how to apply these metrics and understand their implications in real-world scenarios.
  • 🔄 The script concludes by stressing the need for continuous learning and revision of these concepts to ensure a thorough understanding of machine learning model evaluation.

Q & A

  • What is the main topic of the video?

    -The main topic of the video is discussing various metrics used in classification problems for evaluating machine learning algorithms.

  • What are the two types of classification problem statements mentioned in the video?

    -The two types of classification problem statements are those based on class labels and those based on probabilities.

  • What is a confusion matrix?

    -A confusion matrix is a 2x2 table used in binary classification problems to evaluate the performance of a classification model. It includes true positives, true negatives, false positives, and false negatives.

  • What is the default threshold value used in binary classification problems?

    -The default threshold value used in binary classification problems is 0.5.

  • What is the importance of selecting the right metrics for evaluating a machine learning model?

    -Selecting the right metrics is crucial for understanding how well a machine learning model is predicting. Incorrect metrics can lead to a false sense of accuracy, which may result in poor model performance when deployed in production.

  • What is the difference between a balanced and an imbalanced dataset in the context of classification problems?

    -A balanced dataset has approximately the same number of instances for each class, while an imbalanced dataset has a significantly higher number of instances for one class compared to others.

  • Why is accuracy not a reliable metric for imbalanced datasets?

    -Accuracy can be misleading for imbalanced datasets because a model could predict the majority class for all instances and still achieve high accuracy, even if it fails to correctly classify the minority class.

  • What are recall and precision, and when should they be used?

    -Recall (or true positive rate) measures the proportion of actual positives correctly predicted by the model. Precision (or positive prediction value) measures the proportion of predicted positives that are actual positives. They should be used when dealing with imbalanced datasets to focus on reducing false negatives or false positives, respectively.

  • What is the F beta score and how is it related to the F1 score?

    -The F beta score is a measure that combines precision and recall, with a parameter beta that allows for weighting the importance of recall over precision (or vice versa). When beta is equal to 1, the F beta score is known as the F1 score, which gives equal importance to both recall and precision.

  • What are the additional metrics that will be discussed in the next part of the video?

    -In the next part of the video, the presenter plans to discuss Cohen's Kappa, ROC curve, AUC score, and PR curve, along with two more metrics.

  • How will the presenter demonstrate the application of these metrics in the third part of the video?

    -In the third part of the video, the presenter will implement a practical problem statement using an imbalanced dataset and apply the discussed metrics to show how they affect the evaluation of a machine learning model.

Outlines

00:00

📊 Introduction to Classification Metrics

The speaker, Krishna, introduces the video series focusing on classification metrics in machine learning. He outlines the importance of understanding various metrics such as the confusion matrix, accuracy, type 1 and type 2 errors, recall, precision, and F-beta score. The video is structured in parts, with part one covering the basics of classification metrics, part two diving into more complex metrics like Cohen's Kappa, ROC curve, AUC score, and PR curve, and part three applying these metrics to an imbalanced dataset. Krishna emphasizes the significance of choosing the right metrics to evaluate a machine learning model's performance, especially before deploying it in a production environment.

05:01

🔍 Understanding Balanced and Imbalanced Datasets

This paragraph delves into the concepts of balanced and imbalanced datasets in binary classification problems. A balanced dataset is characterized by a similar number of positive and negative outcomes, whereas an imbalanced dataset has a disproportionate ratio of one class to the other. Krishna explains that accuracy is a suitable metric for balanced datasets, but for imbalanced ones, other metrics like recall, precision, and F-beta score are more appropriate. He also introduces the confusion matrix, a 2x2 grid that categorizes predictions into true positives, false positives, true negatives, and false negatives, which is essential for understanding model performance.

10:02

📈 The Importance of Recall and Precision

Krishna discusses the significance of recall and precision in the context of imbalanced datasets. Recall, also known as the true positive rate or sensitivity, measures the proportion of actual positives correctly predicted by the model. Precision, or positive predictive value, indicates the proportion of predicted positives that are true positives. The speaker highlights the importance of reducing both type 1 and type 2 errors and explains how to compute accuracy using the confusion matrix. He also provides examples to illustrate when to prioritize recall or precision based on the problem statement.

15:04

📉 The Role of F-Beta Score in Machine Learning

The paragraph introduces the F-beta score, a metric that combines both recall and precision to provide a balanced measure of model performance, especially in cases where both false positives and false negatives carry significant weight. Krishna explains the formula for calculating the F-beta score and how the choice of the beta value affects the emphasis on precision or recall. He provides guidance on selecting the beta value based on the relative importance of false positives and false negatives in a given problem statement and mentions that the F-beta score can range from F0.5 to F2, with F1 being the harmonic mean of precision and recall.

20:07

🔚 Conclusion and Future Content

In the concluding paragraph, Krishna summarizes the key points covered in the video and previews the content for the upcoming parts of the series. He stresses the importance of understanding and applying the correct metrics for evaluating machine learning models. The speaker encourages viewers to subscribe to the channel and revisit the video for a deeper understanding of the concepts discussed. The next part of the series will cover advanced metrics, and part three will demonstrate the application of these metrics in a practical scenario involving an imbalanced dataset.

Mindmap

Keywords

💡Confusion Matrix

A confusion matrix is a table used to evaluate the performance of a classification model. In the video, it is described as a 2x2 matrix for binary classification, where the rows represent the actual classes and the columns represent the predicted classes. It helps in visualizing the performance of an algorithm by showing true positives, true negatives, false positives, and false negatives. The script mentions it as the basis for understanding other metrics like accuracy, precision, recall, and F-beta score.

💡Accuracy

Accuracy is a performance measurement for classification problems that represents the ratio of correct predictions to the total number of predictions. The video script explains that accuracy is calculated by dividing the sum of true positives and true negatives by the total number of instances. It is noted that accuracy is a good metric for balanced datasets but can be misleading in imbalanced datasets.

💡Type 1 Error

Type 1 Error, also known as a false positive, occurs when a model incorrectly predicts a positive class when the actual class is negative. The video script emphasizes the importance of reducing Type 1 errors and explains that they can be quantified using the false positive rate, which is the proportion of actual negatives that are incorrectly labeled as positives.

💡Type 2 Error

Type 2 Error, also known as a false negative, is when a model incorrectly predicts a negative class when the actual class is positive. The script mentions Type 2 Error in the context of missing out on important positive instances, such as in health care scenarios where not identifying a disease can have serious consequences.

💡Recall

Recall, also referred to as the true positive rate or sensitivity, measures the ability of a classification model to find all the positive instances. The video script explains that high recall is important when the cost of false negatives is high, as in medical diagnosis, where missing a disease can be critical.

💡Precision

Precision, also known as positive predictive value, is the ratio of true positive predictions to the total number of positive predictions made by the model. The script uses the example of spam detection to illustrate the importance of precision, where a low false positive rate ensures that non-spam emails are not mistakenly marked as spam.

💡F-beta Score

The F-beta score is a weighted harmonic mean of precision and recall, where the 'beta' parameter allows for adjusting the relative importance of precision and recall. The video script explains that an F1 score, which is an F-beta score with beta equal to 1, balances the two metrics equally and is used when both false positives and false negatives are equally important.

💡ROC Curve

ROC stands for Receiver Operating Characteristic. The ROC curve is a graphical representation of a classifier's performance, plotting the true positive rate (recall) against the false positive rate (Type 1 Error) at various threshold settings. The script mentions that ROC curves will be discussed in part 2 of the video series, indicating its importance in evaluating classification models.

💡AUC Score

AUC, or Area Under the ROC Curve, is a single scalar value that summarizes the performance of a classification model. AUC measures the entire two-dimensional area underneath the entire ROC curve from 0 to 1. The script indicates that AUC score will be discussed in part 2, suggesting its relevance in understanding the overall effectiveness of a model.

💡Imbalanced Dataset

An imbalanced dataset is one where the number of instances in the different classes are not equal, leading to a higher bias towards the majority class. The video script discusses the challenges of using accuracy in imbalanced datasets and instead suggests using metrics like recall, precision, and F-beta score to better evaluate model performance.

💡Threshold Value

In classification problems, especially in binary classification, the threshold value determines the cutoff point for classifying instances into positive or negative classes. The script explains that the default threshold is often 0.5, but it can be adjusted based on the problem context, such as in healthcare diagnostics where a lower threshold might be chosen to avoid missing positive cases.

Highlights

Introduction to various metrics used in classification problems for evaluating machine learning algorithms.

Explanation of the confusion matrix, a fundamental tool for classification problem analysis.

Discussion on accuracy as a metric for balanced datasets in classification problems.

Introduction to Type 1 and Type 2 errors, crucial for understanding model performance.

Clarification of recall, also known as true positive rate, and its importance in model evaluation.

Precision, or positive predictive value, explained as a key metric for classification accuracy.

Introduction to F-beta score, a metric combining recall and precision for a balanced view of model performance.

The significance of choosing the right metrics to avoid wasting time and resources on ineffective models.

The impact of using incorrect metrics on model performance, especially in a production environment.

Explanation of class labels and probabilities in binary classification and their implications on model output.

The role of threshold values in determining class labels from probabilities in machine learning models.

Differentiation between balanced and imbalanced datasets and their effects on model bias.

The inappropriateness of using accuracy for evaluating models on imbalanced datasets.

How to compute accuracy for balanced datasets and its limitations.

The importance of reducing Type 1 and Type 2 errors to improve model performance.

Practical implementation of metrics on an imbalanced dataset in a future video part.

Upcoming discussion on advanced metrics like Cohen's Kappa, ROC curve, AUC score, and PR curve in part two of the video series.

The necessity to balance false positives and false negatives based on the problem statement's context.

The selection of beta values in F-beta score based on the relative importance of false positives and false negatives.

Final thoughts on the importance of understanding and applying the correct metrics for effective machine learning model evaluation.

Transcripts

play00:00

hello my name is Krishna and welcome to

play00:02

my youtube channel now this was one of

play00:05

the most requested video by you all guys

play00:07

so in this video we'll be discussing

play00:08

about all the metrics in a

play00:11

classification problem statement guys

play00:13

this is just the part one and I have

play00:16

listened down all the important metrics

play00:18

that you can actually use for

play00:20

understanding whether your machine

play00:21

learning algorithm is predicting well or

play00:23

not

play00:24

okay so some of the metrics of a

play00:25

confusion matrix okay

play00:27

then we'll understand about accuracy

play00:29

then we'll understand about type 1 error

play00:31

type 2 error

play00:32

then we have concepts like recall which

play00:35

is also called as true positive red then

play00:37

we will discuss about precision which is

play00:40

also called as positive prediction value

play00:42

okay

play00:43

then we'll understand about F beta and

play00:46

in the next part in the next video we'll

play00:48

basically be understanding about Kohan

play00:50

Kappa ROC curve AUC score and something

play00:54

called as PR curve there are two more

play00:56

metrics again which will I'll discuss in

play00:58

the part two because I do not have space

play01:00

to write it down so we'll just be

play01:02

discussing about that in our next part -

play01:04

in the part three I'll try to implement

play01:06

a problem statement considering an

play01:09

imbalance data set and I'll try to apply

play01:10

all this particular matrix and I'll show

play01:13

you that how the accuracy will look like

play01:14

so make sure guys you watch this

play01:16

particular video completely and make

play01:18

sure that you understand things okay the

play01:21

reason why I am saying even though you

play01:22

are a very very good data scientist and

play01:24

you know how to actually use a machine

play01:27

learning algorithm with respect to your

play01:28

data but if you are not using the

play01:30

correct kind of metrics to find out how

play01:33

good your model is then it is completely

play01:35

a waste of time you know because if you

play01:37

are not selected the right metrics and

play01:39

then you are deployed your model to the

play01:41

production right you'll be able to see

play01:44

that because of the metrics because of

play01:46

the wrong metrics that you have chosen

play01:47

you have chosen that will actually give

play01:50

you a very very bad accuracy again when

play01:52

the model is actually deployed in the

play01:53

production so let us go ahead and try to

play01:55

understand the metrics and in this

play01:57

particular video I will be making like a

play01:59

story ok so part 1 will just be like a

play02:01

story and then I will continue and I

play02:03

will explain you each and every matrix

play02:05

Omega now understand one thing that

play02:07

suppose we have a problem statement so

play02:11

this is a problem statement specifically

play02:13

a classification problem statement ok

play02:17

classification problem statement now in

play02:20

classification problem statement right

play02:23

there are two ways how you can solve the

play02:26

classification problem one way is

play02:28

basically through class labels suppose

play02:31

you want to predict class labels ok the

play02:35

next way is through probabilities

play02:39

probabilities now suppose I if you let

play02:41

me just consider a binary classification

play02:43

in a binary classification I know there

play02:45

will be two different classes A or B

play02:47

suppose this is my a or B so my output

play02:50

will either be a or B ok

play02:52

by default the threshold value will be

play02:56

taken as 0.5 what does this basically

play02:58

mean suppose I am predicting with some

play03:01

of my machine learning model like

play03:02

logistic regression by default if I

play03:05

predict if it is greater than 0.5 then

play03:06

it would become a B class if it is less

play03:08

than 0.5 then it becomes a a class I

play03:11

mean less than or equal to 0.5 then it

play03:12

would become a a class but in case of

play03:14

probabilities here we have to also find

play03:17

out the class labels how we have to

play03:20

basically select the right threshold

play03:22

value which is this p value okay and

play03:25

lots a p value but i instead say some

play03:27

threshold value in some of the health

play03:29

care sector this threshold value may

play03:31

decrease you will be saying that suppose

play03:34

if a person is having cancer or not at

play03:36

that time this threshold value should be

play03:37

chosen in a proper way if it is not

play03:40

chosen in the proper way

play03:41

the person who is having cancer will be

play03:43

missed out right so in probabilities we

play03:47

will be discussing and in probabilities

play03:49

what we have we have basically ROC curve

play03:51

au seeker as a score at PR curve which

play03:54

we'll be discussing in the part 2 in the

play03:56

part 1 we'll be focusing more on this

play03:58

class labels where our default

play04:00

probability is 0.5 okay so I hope you

play04:03

are getting it right so understand that

play04:05

thing if we have a classification

play04:07

problem usually what we do is that they

play04:10

have two types of problem statements

play04:11

over here with respect to the class

play04:12

labels we need to find out what what is

play04:14

the output of that particular record or

play04:17

based on probabilities where we have to

play04:19

first of all find out a threshold value

play04:21

okay in logistic regulation I may find

play04:23

out

play04:24

the threshold value maybe 0.3 maybe 0.4

play04:27

that basically means that if my output

play04:29

is less than or equal to 0.4 it becomes

play04:31

Class A if my output is greater than 0.4

play04:33

then it becomes Class B right and this I

play04:35

will be showing you how you can actually

play04:36

find out with the help of ROC curve and

play04:38

P arca okay so that will come in the

play04:41

part two now let us go ahead one more

play04:44

thing now over here now with respect to

play04:46

this problem statement we have two

play04:48

problem statement based on the output

play04:50

okay based on the output suppose in in

play04:54

this particular problem statement I have

play04:55

thousand records okay

play05:00

I have thousand records okay now with

play05:03

respect to thousand records suppose this

play05:05

is the binary classification problem

play05:06

that basically means suppose I have 500

play05:09

yes that basically 500 records which has

play05:13

a yes as an output and I have 500 no as

play05:17

my other output or I may have 600 years

play05:20

or 400 no right now in this case what I

play05:25

can suggest is that this looks like an

play05:27

in this looks like a balanced data set

play05:30

okay balanced data set basically means

play05:32

that yes you have almost same number of

play05:34

years and same number of no so both then

play05:36

the output labels are almost same

play05:38

similarly if you could take seven

play05:39

hundred years and three hundred no this

play05:41

is also fine this looks like a balanced

play05:43

data set

play05:44

okay now understand one thing guys why

play05:46

why I am saying balanced data set over

play05:49

here the number of years and no are

play05:52

almost equal in this case you may be

play05:54

suggesting Chris there is a difference

play05:56

of four hundred but it is fine why I'll

play05:58

tell you if we have this kind of data

play05:59

set also and if we try to provide this

play06:02

kind of data points to a machine

play06:03

learning algorithm my machine learning

play06:05

algorithm will not get biased based on

play06:07

the maximum number of output okay but if

play06:11

we have scenarios where in our data set

play06:13

ranges and this is basically 70 to 30

play06:16

right 70 to 30 percent basically 70 to

play06:19

30 ratio here you have basically like a

play06:24

60/40 ratio here you have 50/50 ratio

play06:28

right but now if I go one more level

play06:30

down like 8020 ratio 8020 ratio

play06:33

basically means that suppose I have over

play06:35

here 800 record and here I have

play06:36

200 right now in this case when I

play06:40

provide this kind of imbalance dataset

play06:42

to my machine learning algorithm some of

play06:44

the machine learning algorithm will get

play06:46

biased based on the maximum number of

play06:48

output okay now if we have a balanced

play06:51

data set if we have a balanced data set

play06:54

the type of metrics that is basically

play06:56

used is something called as accuracy if

play06:58

we have an imbalance data set at that

play07:02

time we do not consider accuracy instead

play07:05

we consider something called as recall

play07:07

precision and F beta I'll explain you

play07:09

about what exactly is a beta score which

play07:12

is also called as the f1 score if you

play07:13

have heard of most of it but this f1

play07:16

score is derived by this beta value that

play07:18

will it be discussing about now this

play07:20

consider guys initially let us take that

play07:23

suppose my data set is balanced okay at

play07:26

that time I'll try to explain your

play07:27

accuracy and then we will then

play07:30

understand if our data becomes

play07:31

imbalanced how do we solve this

play07:33

particular problem okay so let us go

play07:35

ahead I am just going to rub this thing

play07:36

and if you have not understood just you

play07:40

know just go back again see this

play07:41

particular explanation what I've given

play07:43

okay now first of all if we have a

play07:46

binary classification problem guys we

play07:48

need to understand what exactly is the

play07:49

confusion matrix now understand one

play07:52

thing guys concision matrix is nothing

play07:53

but it is a 2 cross 2 matrix in case of

play07:56

binary classification problem where the

play07:59

top values are actually the actual

play08:02

values okay the top values are the

play08:05

actual values over here actual values

play08:07

like 0 or 1 1 or 0 suppose I have to

play08:09

consider this as 1 and 0 and similarly

play08:11

in the left hand side this all mehar my

play08:14

predicted values so this basically

play08:17

values indicates that what my model has

play08:19

actually predicted so this will also

play08:20

become 1 and 0 so usually what we do is

play08:24

that each and every field we specify

play08:26

with some notations so the first field

play08:28

in this case is something called as true

play08:30

positive the second field is something

play08:32

called as true false positive and the

play08:35

third field is something called as false

play08:37

negative and the fourth field is

play08:38

something called as true negative we'll

play08:40

try to understand more in depth what

play08:41

exactly this of these fields mean okay

play08:44

what is false positive what is false

play08:45

negative and by default if I consider

play08:47

this type 1 this is called as

play08:49

type one error okay

play08:53

so if I want to consider this false

play08:55

positive this is basically called as a

play08:56

type 1 error we we can also compute the

play08:59

type 1 error with the help of false

play09:02

positive rate okay false positive rate I

play09:05

will define the formula in just a while

play09:06

this FN is basically called as a type 2

play09:11

error and this is also mentioned like

play09:15

false negative rate now what is what do

play09:19

what does this false positive mean now

play09:22

if you want to define false positive

play09:23

error how do we do is that we basically

play09:25

consider this false values with respect

play09:29

to your actual and predicted and the

play09:31

false positive rate is basically given

play09:32

by FB / FP plus TN okay this true

play09:37

negative and this and always remember

play09:39

guys these are your most accurate

play09:41

results okay TP and DL and always your

play09:44

aim should be okay in any classification

play09:47

problem to reduce your type 1 error and

play09:49

to reduce your type 2 error okay you

play09:52

always have to focus on reducing your

play09:54

type 1 error and reducing your type 2

play09:56

error okay now understand one thing guys

play09:59

since this is a balanced problem

play10:01

statement right so what we do is that we

play10:04

directly compute the accuracy now how

play10:07

does we how do we compute the accuracy

play10:09

is that we simply add T P plus TN PP +

play10:15

TN / TP plus FP + SN + TN that basically

play10:23

means I am just saying that this

play10:25

diagonal elements which will actually be

play10:27

giving me the right result divided by

play10:29

total number of residents and this will

play10:30

give us the accuracy why I am following

play10:33

this particular stuff because I'm

play10:34

considering this problem statement is my

play10:36

balance data set okay

play10:38

and during the balance data set usually

play10:40

my model does not get biased based on

play10:43

the different types of categories that

play10:45

we have in this binary classification

play10:46

problem okay but now what is what if my

play10:50

data set is not balanced what if my data

play10:53

set is not balanced let me give you a

play10:54

very good example suppose one category 1

play10:58

category I have some one hundred nine

play11:00

hundred values suppose out of the

play11:02

thousand records

play11:02

I have nine hundred one category and one

play11:05

hundred as my another category okay 100

play11:09

as my another category now if I apply

play11:11

just understand over here guys if I just

play11:14

say that my model will bluntly say that

play11:17

everything belongs to category A and not

play11:20

to category B okay not to category B but

play11:24

instead it will say that every I mean

play11:26

every values or every touch data set

play11:29

belongs to my category a instead of

play11:31

category B okay so out of this I am just

play11:34

suggesting that okay 900 values and I am

play11:37

considering this is my touch data

play11:38

suppose days okay suppose I am having

play11:41

this test data or just consider that I

play11:43

had my train data in my train did I had

play11:45

1500 records out of which 1200 was my a

play11:49

Class C category and 300 was my Class B

play11:52

category and now I have divided that

play11:54

into train - split my in my inside my

play11:57

test data suppose I had around I'm just

play11:59

considering an example in my test data I

play12:01

had Class A as 900 records and Class B

play12:04

has 100 records now suppose if my model

play12:07

predicted all the classes over Class A

play12:09

now in that specific place if I said TP

play12:12

plus TN I'm just going to get the 90%

play12:14

accuracy right because they're true

play12:16

positive I will be getting 900 true

play12:19

negative I will be getting 0 and if I do

play12:21

the summation of all of this this will

play12:22

be some thousand and this is in short

play12:24

90% dozen of my accuracy right so this

play12:27

is a problem right if we have an

play12:29

imbalanced data set we cannot just use

play12:31

accuracy because it will give you a very

play12:33

very bad meaning about that particular

play12:35

model you know you're just blindly

play12:37

saying that it belongs to just one

play12:38

category so if you have an imbalanced

play12:41

data set you basically go with something

play12:44

called as recall precision right and

play12:47

something called as FB toughs code now

play12:50

let us go ahead and try to understand

play12:51

about recall and precision okay guys now

play12:55

let us go ahead and just understand what

play12:57

exactly is recall and precision

play12:59

now guys here is my confusion matrix

play13:00

here you have through positive false

play13:02

positive false negative and true

play13:04

negative I understand why do we use this

play13:06

for an imbalanced data set now

play13:08

understand one thing guys any kind of

play13:10

data set that you have you should always

play13:12

try to reduce your type

play13:14

one error and type 2 error okay you

play13:16

should always try to reduce this now

play13:18

specifically when your data set is

play13:20

imbalanced we should either focus on

play13:22

recall and precision now what does

play13:24

recall over here formula says recall

play13:27

basically says that TP TP so these are

play13:30

my actual values right these are my

play13:32

actual these are my predicted values so

play13:35

this basically says that TP / TP plus FN

play13:39

okay TP / TP plus FN now what does this

play13:43

says that out of the total positive

play13:46

actual values how many values did be

play13:49

correctly predicted positively okay this

play13:52

is what this recall basically says again

play13:54

I am repeating it guys out of the total

play13:57

actual positive values one is positive

play13:59

right I can say true or positive

play14:01

anything out of all this how many

play14:04

positive did we predict correctly that

play14:07

is what this recall basically says

play14:09

recall is also given by something called

play14:11

as true positive rate it is also

play14:13

mentioned by true positive rate or it is

play14:15

also mentioned by sensitivity okay it is

play14:18

also mentioned by sensitivity now

play14:20

similarly if I consider about precision

play14:22

it basically says TP / TP + SB okay now

play14:27

what does this basically say out of the

play14:30

total predicted positive result how many

play14:34

results are actual positives okay here

play14:37

we are actually focusing on the false

play14:39

positives here in the record we were

play14:41

actually focusing on false negatives

play14:42

right so again I am repeating it what

play14:45

does precision basically say out of the

play14:48

total actual positive predicted results

play14:51

how many were actually positive and what

play14:55

is the prop proportion that were actual

play14:57

positive that is what this particularly

play14:59

precision basically say and for

play15:00

precision we also specify another name

play15:03

which is called as positive prediction

play15:05

value suppose in your interview they

play15:07

asked you what is actually positive

play15:08

prediction value you have to explain the

play15:10

same thing understand this thing guys

play15:12

now when should we use a recall and

play15:15

precision understand guys let me just

play15:18

give you some very good example of

play15:20

recall and precision so I have a use

play15:22

case which is called as spam detection

play15:28

in spam detection I have to focus on

play15:31

precision why consider that suppose in

play15:35

this false positive which basically says

play15:37

that suppose this this mail is not a

play15:39

spam okay suppose it is mail is not a

play15:41

spam but the model has predicted that it

play15:44

is a spam that is your false positive

play15:46

okay this again I'm telling you guys the

play15:48

mail is not a spam but it has been

play15:51

predicted that it is a spam so this is

play15:53

what it is saying zero basically means

play15:55

not a spammer

play15:56

but it has predicted that it is a spam

play15:58

now in this particular scenario what

play16:00

will happen is that we should try to

play16:02

reduce this false positive value we

play16:04

should try to reduce it false positive

play16:05

value because I understand in this case

play16:07

in a spam mail detection if it is not a

play16:10

spam and if it is specified or predicted

play16:12

as a spam the customer is going to miss

play16:14

that particular mail which may be a very

play16:16

important mail itself right so because

play16:19

of that we should always try to reduce

play16:20

this false positive value in the case of

play16:23

this kind of use case that is spam

play16:24

detection but what about recall suppose

play16:27

I say that whether the person is having

play16:28

cancer or not cancer or not okay so my

play16:33

one value basically specifies that he is

play16:35

having cancer 0 specifies that he is not

play16:37

having cancer now in this particular

play16:39

case we should try to reduce false

play16:41

negative

play16:41

why understand this guys this one now

play16:44

consider that if the person is having a

play16:47

cancer actually is having a cancer but

play16:49

he is predicted as that the person is

play16:52

not having by the model okay so that is

play16:54

what say so yeah these are natural

play16:56

values suppose is he he is suffering

play16:58

from cancer so that what what exactly

play17:00

the actual value says right but the

play17:02

model has predicted that the person is

play17:04

not having a cancer so this may be a

play17:06

disaster because I can understand if I

play17:10

get an error in false positive then the

play17:12

person will go with another for the test

play17:14

to understand whether he is having

play17:15

cancer or not but if my model predicted

play17:18

that even though he had a cancer but

play17:20

here so he was predicted as he was not

play17:21

having a cancer so this is the disaster

play17:23

at that time we should specifically use

play17:26

recall now in short guys whenever your

play17:29

false positive is much more important

play17:32

whenever your false positive is much

play17:35

more important go and blind

play17:37

use precision whenever with respect to

play17:41

your problem statement if your recall

play17:44

with your false negative is important at

play17:46

that time you go and use recall I gave

play17:50

you an example guys okay cancer whether

play17:52

a person is having cancer or not some

play17:54

more examples whether tomorrow the stock

play17:57

market is going to crash or not some

play18:00

example of precision spam detection

play18:01

right consider this particular example

play18:04

try to think always our aim should be to

play18:07

reduce false positive and false negative

play18:09

but whether false in the positive is

play18:11

playing a greater impact or role in that

play18:14

specific model if we displayed go and

play18:16

use precision focus on precision if

play18:18

false negative is actually playing a

play18:20

greater role or if greater impact it is

play18:22

having this go and use recall now I want

play18:26

to introduce you to something bad as f

play18:28

beta now sometimes in some of the

play18:30

problem statements guys false positive

play18:32

and false negative both are very very

play18:34

important okay in an imbalance data set

play18:37

I'm saying okay both will be important

play18:39

at that time we have to consider both

play18:41

recall and precision and if you want to

play18:44

reconsider both recall and precision we

play18:46

basically use FB does score okay FB does

play18:51

code and sometimes in some of the

play18:52

problem statements guys even though

play18:54

recall play a major role that is like

play18:56

false negative player is major role or a

play18:58

false positive play a major role you

play19:01

know some of the problem statement you

play19:02

should try to combine both precision and

play19:04

recall to get the most accurate value so

play19:07

for that particular case we use a as

play19:09

beta score now here I'm going to define

play19:11

a F beta school formula for you so that

play19:14

you'll be able to understand so now let

play19:17

us go ahead and understand what exactly

play19:18

is the F beta score guys in F beta

play19:21

usually the main aim is to select this

play19:23

beta value okay now how we should go

play19:26

ahead and select the beta value I'll

play19:28

just tell you in a minute

play19:29

but just understand one thing guys this

play19:31

exactly if I just consider my beta value

play19:34

is one okay this basically becomes an f1

play19:38

score okay

play19:39

this basically becomes an f1 score how

play19:42

to select when to select beta is equal

play19:44

to one

play19:44

I'm just going to tell you in a while

play19:46

similarly beta values can vary it can

play19:49

also be less than one

play19:50

one it can be 0.5 it can be - you know

play19:53

if it is 0.5 we basically say this as f

play19:56

0.5 score if it is 2 means basically say

play20:00

that F 2 score okay now I hope I don't

play20:06

know whether you have seen this

play20:07

particular formula guys but just

play20:09

understand this is my F beta and

play20:10

initially we need to select this

play20:12

particular beta value now consider that

play20:14

it's my beta values 1 now this formula

play20:17

basically becomes 2 into precision

play20:21

multiplied by recall divided by

play20:26

precision plus recall okay and this is

play20:31

basically called as a if you don't know

play20:34

about this guy this is called as a

play20:35

harmonic mean harmonic mean if I replace

play20:40

this precision recall by X X - x + y so

play20:43

this will become 2 X Y divided by x + y

play20:46

I hope you have been formula with this

play20:49

particular formula itself this was we've

play20:51

used in some of the linear algebra in

play20:54

your school days and in your college

play20:56

days if you remember - XY / x + y I'm

play20:59

considering precision and X recall as Y

play21:01

precision over AR x x + y okay now

play21:05

understand over here

play21:06

when should we select beta is equal to 1

play21:08

now understand guys if you have a

play21:10

problem statement where wherever through

play21:13

positive sorry not true positive false

play21:15

positive and false negative both are

play21:17

equally important both are having a

play21:20

greater impact at that time you go and

play21:23

select beta is equal to 1 okay now in

play21:26

some of the scenarios suppose you're

play21:28

false positive is having more impact

play21:30

than the false negative that is then the

play21:33

type 2 error okay false positive is the

play21:35

type 1 error at that time you reduce

play21:38

your beta value to 0.5 between between 0

play21:41

to 1

play21:41

usually people select it as 0.5 at that

play21:44

time this beta value will get converted

play21:46

to 0.5 so it will be 1 point 1 plus 0.25

play21:49

this is nothing but 1 point 2 5

play21:52

multiplied the precision in to recall

play21:54

divided by this will basically become

play21:56

0.25 into precision + record so whenever

play21:59

your false positive is more important

play22:01

we reduce this beta value now similarly

play22:04

if my false negative is high false

play22:07

negative impact is high right that is

play22:09

for recall if you remember guys okay if

play22:12

that is high at that time we

play22:13

specifically increase my beta value

play22:16

greater than 1 suppose I consider it as

play22:18

2 right at that time what will happen

play22:21

again I'll have to try to apply in this

play22:22

beta value this particular 2 value this

play22:24

is nothing will but 5 multiplied by

play22:26

appreciation into recall divided by 4

play22:29

multiplied by precision plus recall so

play22:32

if if false negative and false positive

play22:35

are both important we consider beta is

play22:37

equal to 1 if false positive is more

play22:40

important at that time what we do we

play22:42

reduce the beta value if false negative

play22:46

is having an higher impact we increase

play22:48

the beta value and that is how we select

play22:50

this F beta value and sometimes we say

play22:53

it as f1 score sometimes we say it as f2

play22:55

score sometimes we say say it as f 0.5

play22:59

score okay considering this particular

play23:01

values and again guys

play23:03

based on this false negative also

play23:06

sometimes your beta value ranges between

play23:08

1 to 10 okay considering where your

play23:11

false negative is having a greater

play23:12

impact when you have false visit

play23:14

positive is having a greater impact you

play23:16

basically select a value somewhere

play23:17

between 0 to 1 and that is why you

play23:20

specifically use F beta whether you want

play23:23

to combine both precision recall and try

play23:26

to showcase a particular problem

play23:27

statement and try to select the right

play23:29

kind of metrics this each and every

play23:31

parameter is very very important guys so

play23:34

I hope you understood this particular

play23:36

videos guys in the part 2 will be

play23:37

discussing about Kohan Kappa ROC curve

play23:39

AUC score PR curve and there are some

play23:42

more two more metrics which I am going

play23:43

to discuss in the next part 2 in the

play23:45

part 3 we will basically be implementing

play23:48

a practical problem statement to make

play23:50

you understand all these particular

play23:51

things so I hope you like this

play23:53

particular video I know this is too much

play23:55

just go revise it you get to know each

play23:58

and everything so yes this was all about

play24:00

this particular video I hope you liked

play24:01

it please do subscribe the channel if

play24:02

you have not already subscribe in the

play24:04

next video have a great day ahead thank

play24:05

you one at all

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
Machine LearningClassificationMetricsAccuracyPrecisionRecallF-Beta ScoreConfusion MatrixImbalanced DataROC CurveAUC Score
¿Necesitas un resumen en inglés?