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

Krish Naik
27 Jan 202024:12

Summary

TLDRتشرح القناة اليوتيوبية في هذا الفيديو عن معايير التصنيف في مسائل التصنيف، ويغطي الفهرس الخلطي والدقة والأخطاء النوع 1 والنوع 2، والاسترجاع والدقة والF beta. سيناقش القناة في الأجزاء القادمة المزيد من المعايير مثل ROC المنحنى وAUC النتيجة والمنحنى PR، ويشرح التطبيق الفني في الجزء الثالث مع بيانات مكتوبة.

Takeaways

  • 📊 الemetrika في مشاكل التصنيف: النص يناقش مجموعة واسعة من الemetrika التي يمكن استخدامها لتقييم الخوارزميات الذكاء الاصطناعي في المشاكل التصنيفية.
  • 🔍 الفهرس الخلطي: يشرح النص مفهوم الفهرس الخلطي ويشرح القيم الحقيقية والمتوقعة والعلاقات بينها.
  • ✅ الدقة: يناقش النص كيف يتم حساب الدقة في المشاكل التصنيفية وكيف يعتمد على القيم ال对角 في الفهرس الخلطي.
  • 🔺 الأخطاء النوع 1 والنوع 2: يحدد النص الأخطاء النوع 1 (falase positive) والأخطاء النوع 2 (falase negative) وتأثيرهما على الدقة.
  • 🔍 التذكير: يشدد النص على أهمية فهم الemetrika الصحيحة للتقييم الصحيح للمودل الذكاء الاصطناعي.
  • 📉 التوازن في المجموعة البيانات: يناقش النص الفرق بين مجموعات بيانات متوازنة وغير متوازنة وتأثير ذلك على الemetrika المختارة.
  • 🔎 الذاكرة (Recall): يشرح النص معنى الذاكرة وتوضح كيف يعتمد على عدد القيم الصحيحة المحددة بشكل صحيح.
  • 🎯 الدقة (Precision): يناقش النص الدقة ويشرح كيف يعتمد على نسبة القيم الصحيحة من بين القيم المتوقعة بشكل إيجابي.
  • 🤖 F beta: يشرح النص مفهوم F beta ويشرح كيف يجمع بين الدقة والذاكرة لتقييم المودل بشكل متوازن.
  • 📈 الاستخدام الصحيح للemetrika: يشدد النص على ضرورة اختيار الemetrika الصحيحة بناءً على أهمية الأخطاء الfalase positive والfalase negative في ال.problem.
  • 👨‍🏫 تطبيق الemetrika: يوعد النص بتطبيق الemetrika التي تمت مناقشتها في حل مشكلة تصنيف مع مجموعة بيانات غير متوازنة في الجزء الثالث من الفيديو.

Q & A

  • ما هي المعايير التي تناقشها في هذا الفيديو؟

    -يناقش هذا الفيديو مجموعة من المعايير التي تتضمن مصفوفة الخلط، دقة، خطأ النوع 1، خطأ النوع 2، تذكر (True Positive Rate)، دقة (Positive Prediction Value)، وF beta.

  • ما هي الفرق بين الدقة والتذكر؟

    -الدقة تشير إلى عدد النتائج الصحيحة الإيجابية من بين النتائج المتوقعة الإيجابية، بينما التذكر تشير إلى عدد القيم الصحيحة الإيجابية التي تم توقعها بشكل صحيح من بين جميع القيم الفعلية الإيجابية.

  • لماذا لا يُنصح باستخدام الدقة لتقييم النماذج في المجموعة غير التوازنة؟

    -في المجموعة غير التوازنة، يمكن أن تؤدي الدقة إلى تقييم خاطئ للنموذج، حيث يمكن أن يتوقع النموذج جميع الإدخالات كفئة واحدة، مما يؤدي إلى دقة عالية ولكن لا تعكس الأداء الحقيقي للنموذج.

  • ما هي مصفوفة الخلط؟

    -مصفوفة الخلط هي مصفوفة 2x2 تستخدم في التصنيف لتحديد عدد القيم الصحيحة الإيجابية، القيم الصحيحة السلبية، القيم الخاطئة الإيجابية، والقيم الخاطئة السلبية.

  • ما هو F beta النتيجة؟

    -F beta النتيجة هي معيار يجمع بين الدقة والتذكر، ويتيح تحديد الأهمية النسبية للأخطاء الخاطئة والأخطاء السلبية استنادًا إلى قيمة beta، التي يمكن أن تحدد الأهمية المرجوة للأخطاء الخاطئة والأخطاء السلبية.

  • كيف يمكننا استخدام معيار F beta لتحسين تقييم النموذج؟

    -يمكننا استخدام معيار F beta لتحسين تقييم النموذج عن طريق ضبط قيمة beta بناءً على الأهمية النسبية للأخطاء الخاطئة والأخطاء السلبية في المسألة المحددة، مما يتيح لنا الحصول على معيار يعكس بشكل أفضل أداء النموذج.

  • ما هي الفرق بين الأخطاء النوع 1 والأخطاء النوع 2؟

    -أخطاء النوع 1 هي الأخطاء الخاطئة الإيجابية، التي تعني توقع أن العنصر هو من فئة معينة عندما يكون في الواقع من فئة أخرى. الأخطاء النوع 2 هي الأخطاء الخاطئة السلبية، التي تعني توقع أن العنصر ليس من فئة معينة عندما يكون في الواقع من تلك الفئة.

  • لماذا يُنصح بتقليل الأخطاء الخاطئة الإيجابية والأخطاء الخاطئة السلبية في التصنيف؟

    -تقليل الأخطاء الخاطئة الإيجابية والأخطاء الخاطئة السلبية يساعد على تحسين دقة التصنيف وتقليل التأثير السلبي للأخطاء في القرار النهائي، مما يؤدي إلى تحسين أداء النموذج بشكل عام.

  • ما هي الأهمية من استخدام ROC المنحنى والنقاط AUC في التصنيف؟

    -ROC المنحنى والنقاط AUC هي معايير تحليلية تساعد في تقييم القدرة على التمييز بين الفئات المختلفة في التصنيف، مما يوفر نظرة شاملة على أداء النموذج في مختلف القيم العتبة.

  • ما هي الخطوات التالية التي سيتم تغطيتها في الفيديوهات القادمة؟

    -في الفيديوهات القادمة، سيتم تغطية معايير Kohan Kappa، ROC المنحنى، نقاط AUC، PR المنحنى، والمزيد من المعايير التي لم يتم تغطيتها في هذا الفيديو.

Outlines

00:00

📊 Introduction to Classification Metrics

Krishna introduces the video series focusing on classification metrics in machine learning. He outlines the importance of using the right metrics to evaluate a model's performance and mentions that incorrect metrics can lead to poor model performance in production. The video will cover confusion matrix, accuracy, type 1 and 2 errors, recall, precision, and F-beta score. The series will also discuss advanced metrics like Cohen's Kappa, ROC curve, AUC score, and PR curve in subsequent parts.

05:01

🔍 Understanding Confusion Matrix and Accuracy

The paragraph explains the concept of a confusion matrix in binary classification and its components: true positive, false positive, false negative, and true negative. It discusses the importance of reducing type 1 and type 2 errors. The paragraph then delves into calculating accuracy for balanced datasets, emphasizing that accuracy may not be a reliable metric for imbalanced datasets due to the potential for biased predictions.

10:02

📈 Dealing with Imbalanced Datasets

Krishna addresses the challenge of imbalanced datasets, where one class significantly outnumbers the other. He explains that accuracy is not a suitable metric in such cases and introduces recall, precision, and F-beta score as more appropriate metrics. The paragraph discusses the importance of these metrics in evaluating model performance when the dataset is skewed.

15:04

🛠 Precision and Recall: When to Use Them

This section provides a detailed explanation of precision and recall, including their formulas and significance. Krishna uses the example of spam detection to illustrate the importance of precision in minimizing false positives. Conversely, he uses the example of cancer diagnosis to highlight the critical nature of recall in avoiding false negatives, emphasizing the need to choose between precision and recall based on the specific impact of false positives and false negatives in a given problem.

20:07

🎯 The F-Beta Score: Balancing Precision and Recall

Krishna introduces the F-beta score as a way to balance precision and recall, especially when both false positives and false negatives are significant. He explains the formula for the F-beta score and how the beta value can be adjusted to emphasize either precision or recall, depending on the problem statement. The paragraph also discusses the selection of beta values and the scenarios in which they are applied.

🔚 Conclusion and Future Content

In the concluding paragraph, Krishna summarizes the video's content and previews upcoming topics in the series, including Cohen's Kappa, ROC curve, AUC score, PR curve, and additional metrics. He encourages viewers to subscribe to the channel and to review the material to fully understand the concepts presented. Krishna also hints at a practical implementation in part 3 of the series to solidify the viewers' understanding of the discussed metrics.

Mindmap

Keywords

💡Metrics

_metrics_ هي المعايير التي تساعد في تقييم وتقييم أداء الخوارزميات الآلية في مسائل التصنيف. في النص، يتم استخدام _metrics_ لفهم ما إذا كانت خوارزم التعلم العميق تتنبأ بشكل جيد أم لا. مثل الدقة والخطأ النوع 1 والخطأ النوع 2، ومؤشرات أخرى مثل التذكار والدقة التي تساعد على التعرف على جودة التنبؤات.

💡Confusion Matrix

_matrix_ هي مصفوفة 2x2 تستخدم في التصنيف لتوضيح النتائج الفعلية والمتوقعة من الخوارزميات الآلية. في النص، يتم استخدام _confusion matrix_ لتوضيح الفرق بين النتائج الصحيحة والغير صحيحة، بما في ذلك القيم الحقيقية الإيجابية والسلبية والتوقعات الصحيحة والغير صحيحة.

💡Accuracy

الدقة _accuracy_ هي معيار يستخدم لتقييم الأداء العام للخوارزميات الآلية في التصنيف، ويظهر النسبة التي ت猜測 بشكل صحيح. في النص، يوضح الكاتب كيف يمكن حساب الدقة وكيف يمكن أن تكون غير فعالة في الatasets الغير متوازنة.

💡Type 1 Error

الخطأ النوع 1 _type 1 error_ هو الخطأ الذي يحدث عندما ي猜測 الخوارزمية أن العنصر هو من فئة معينة عندما في الواقع هو من فئة أخرى. في النص، يُعرف هذا الخطأ بـ _false positive_ ويتم توضيح كيف يمكن حساب معدل الخطأ النوع 1.

💡Type 2 Error

الخطأ النوع 2 _type 2 error_ هو الخطأ الذي يحدث عندما ي猜測 الخوارزمية أن العنصر ليس من فئة معينة بينما في الواقع هو. في النص، يُعرف هذا الخطأ بـ _false negative_ ويتم توضيح كيف يمكن حساب معدل الخطأ النوع 2.

💡Recall

التذكار _recall_ هو معيار يستخدم لتقييم القدرة على اكتشاف الحالات الصحيحة في التصنيف. في النص، يُستخدم _recall_ لوصف عدد الحالات الصحيحة التي تم اكتشافها بشكل صحيح من المجموعة الكلية من الحالات الفعلية.

💡Precision

الدقة _precision_ هي معيار يستخدم لتقييم الدقة في النتائج المتوقعة من الخوارزميات الآلية. في النص، يُستخدم _precision_ لوصف عدد الحالات الصحيحة التي تم اكتشافها من الحالات التي تم افتراضها كصحيحة.

💡F Beta Score

F beta score هو معيار يجمع بين الدقة والتذكار لتقييم الأداء العام للخوارزميات الآلية في التصنيف. في النص، يُستخدم F beta score ل平衡 بين الأخطاء النوع 1 والنوع 2، ويتم توضيح كيف يمكن اختيار قيمة beta بناءً على الأهمية النسبية للأخطاء.

💡ROC Curve

ROC curve هي منحنى يستخدم لتوضيح الأداء الإجمالي للخوارزميات الآلية في التصنيف. في النص، يُستخدم ROC curve لتوضيح كيف يمكن تقييم القدرة على التمييز بين الحالات الفعلية والغير حقيقية.

💡AUC Score

AUC score هي معيار يستخدم لتقييم مدى جودة ROC curve. في النص، يُستخدم AUC score لوصف الأداء الإجمالي للخوارزمية، حيث越高 AUC score أ越好 الأداء للخوارزمية.

Highlights

Introduction to a variety of metrics used in classification problems in machine learning.

Explanation of the importance of selecting the right metrics for evaluating machine learning models.

Discussion on the use of confusion matrix as a fundamental tool for classification problem evaluation.

Clarification of the difference between type 1 and type 2 errors in classification.

Introduction to recall, also known as true positive rate, as a key metric for classification problems.

Definition and importance of precision, also known as positive predictive value, in classification.

Explanation of F beta score as a balance between precision and recall for classification problems.

Introduction to the concept of ROC curve and AUC score for evaluating classification models.

Discussion on the challenges of using accuracy as a metric in imbalanced datasets.

Emphasis on the need for different metrics like recall, precision, and F beta in imbalanced datasets.

Illustration of how to interpret the confusion matrix for binary classification problems.

Explanation of the implications of threshold values in classification, especially in healthcare.

Introduction to the concept of balanced and imbalanced datasets in the context of classification.

Discussion on the impact of dataset imbalance on the bias of machine learning models.

Explanation of how to compute accuracy for balanced datasets in classification problems.

Introduction to the concept of false positive rate and its calculation.

Emphasis on the goal of minimizing type 1 and type 2 errors in classification problems.

Introduction to the F beta score formula and its significance in combining precision and recall.

Discussion on the selection of beta value in F beta score based on the importance of false positives and false negatives.

Preview of upcoming videos covering additional metrics and practical implementation on imbalanced datasets.

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)

الوسوم ذات الصلة
تصنيفالذكاء الاصطناعيمصفوفة الخلطدقةدقة الكشفأخطاء التصنيفمؤشر FROC المنحنىAUC النتيجةPR المنحنىبيانات غير متوازنة