Naive Bayes Classifier | Part 7 | Mathematics behind Naive Bayes Algorithm — Transcript
Full transcript
- 0:02So now let's do the mathematics part of
- 0:04this algorithm.
- 0:06Uh to be honest uh
- 0:08which points to that
- 0:09but other last video says it follow
- 0:11here.
- 0:12So what if it didn't work here? So
- 0:15what we are going to do in this video is
- 0:17we are going to derive the formula.
- 0:19And to be last thing we used here was
- 0:21mathematically derived from here.
- 0:23Or along the way seeking it key in life
- 0:26assumption here life is here. So let's
- 0:29start.
- 0:30Uh so let's start with this
- 0:34uh vector.
- 0:36Let's say
- 0:37X1 X2 X3
- 0:42XN.
- 0:44And uh
- 0:47uh this
- 0:49uh
- 0:51target variable C1 C2 C3
- 0:54up till CK.
- 0:57This is capital K. This is small K. Now
- 1:00I think it's
- 1:00difficult to see
- 1:02it's a very simple thing.
- 1:09So there was toss.
- 1:11Uh there was venue.
- 1:13And there was outlook.
- 1:16Right? And there was result.
- 1:18Or last time it was a two class
- 1:20classification if you remember. Yes. I'm
- 1:22sorry.
- 1:23Won
- 1:25or lost. Basically this is what we have
- 1:27to do here. I don't know if this model
- 1:29will follow X1
- 1:31X2 X3.
- 1:33So you have three things only. Okay?
- 1:35Or similarly yeah C1
- 1:38or won.
- 1:39And C2
- 1:41lost.
- 1:42Yeah.
- 1:43Okay. So we have a general case like
- 1:45that. You want to make N columns. So my
- 1:48X1 X2 X3 XN
- 1:50or you may
- 1:52there are this is a multi-class label or
- 1:55a
- 1:55problem. Okay? This is a binary problem,
- 1:58binary class classification. So, there
- 2:00was there is only C1 and C2. You have to
- 2:02have what? K classes. Okay? So, there
- 2:04are
- 2:04K classes. It's a K class
- 2:07classification.
- 2:08So, I guess you all are pointing here.
- 2:10Okay? So,
- 2:12I'll remove this.
- 2:18Now,
- 2:19uh
- 2:21you remember this, right? What we have
- 2:23to do is
- 2:25for every C, C1, C2, C3, I have to find
- 2:28out this, probability of
- 2:32C
- 2:33K, but you have to pay. One is the
- 2:35probability of the general K given
- 2:39X.
- 2:41You can do it.
- 2:44So, probability of C K given X.
- 2:54C2.
- 2:56Okay? Uh
- 3:02So, it's going to be
- 3:04I'm just writing it this way.
- 3:06So, we need to get back to that. Okay?
- 3:08And now, according to Bayes' theorem, we
- 3:11already know this that that this would
- 3:13become
- 3:14X given
- 3:16C K multiplied by probability of
- 3:19C K divided by probability of
- 3:23X.
- 3:24Right?
- 3:25Or
- 3:31This term is going to be common
- 3:34everywhere. So,
- 3:38So, what we will do is we'll remove
- 3:40this.
- 3:42So, we are left with this term.
- 3:44Okay?
- 3:47Now,
- 3:48if you remember conditional probability,
- 3:50according to conditional probability,
- 4:01right?
- 4:02So,
- 4:06probability of A given B multiplied by
- 4:08probability of B, this will be
- 4:10probability of A intersection B, right?
- 4:15So,
- 4:16what we will do is we'll use this logic
- 4:19over here.
- 4:22I will write
- 4:24probability of
- 4:26CK happening given X will actually be
- 4:30equal to probability of
- 4:33X
- 4:34intersection
- 4:36CK.
- 4:37This is basic
- 4:39conditional probability.
- 4:47Uh you already know this that you can
- 4:49replace this with a comma,
- 4:51right? So,
- 4:54I'm going to go ahead and instead of
- 4:55writing this, we are writing this.
- 4:58X comma
- 5:00CK.
- 5:04Now,
- 5:05equal to
- 5:08Don't you think I can break down X into
- 5:11X1 {comma} X2 {comma} X3 {comma}
- 5:15XN {comma}
- 5:17CK?
- 5:28X is actually equal to
- 5:30X1 intersection X2 intersection X3
- 5:34intersection XN.
- 5:49Right?
- 5:55What we are doing is come is done cool.
- 5:58X1 cool.
- 5:59A minor.
- 6:01Or is for a damn cool.
- 6:06B minor.
- 6:07Okay, so in a way in between we got it.
- 6:10This.
- 6:11Up again.
- 6:13By.
- 6:15Conditional probability we know this.
- 6:17This can be replaced.
- 6:21With this.
- 6:23This is conditional probability.
- 6:29Probability of. A given B. So this is A.
- 6:34X1.
- 6:35Given.
- 6:37X2 {comma} X3.
- 6:40XN {comma}
- 6:42CK.
- 6:48I just want to know
- 6:49to get.
- 6:50Now you want to
- 6:52probability of B. So probability of B
- 6:55would become this.
- 6:59X2 {comma} X3 {dot} {dot} {dot} {comma}
- 7:03XN {comma}
- 7:06CK.
- 7:07I guess it's not so much
- 7:08to get.
- 7:09Up a counter.
- 7:11This
- 7:12is not going to be too much let's say
- 7:14it's going to be cool.
- 7:16You get more than let's call it A.
- 7:19Okay, so you can actually write.
- 7:22Probability.
- 7:24Of. CK. Given X is equal to A multiplied
- 7:31by.
- 7:32Probability of X2.
- 7:35X3.
- 7:37XN.
- 7:38CK.
- 7:40Right.
- 7:43Up cool social is done cool cool.
- 7:47Probability of
- 7:49X1, sorry, not one. Two is the start of
- 7:52the year. X3
- 7:54XN {comma} CK.
- 7:58Don't you think you have to be the same
- 7:59assumption applied to the system? What I
- 8:01can do is I can assume this thing to be
- 8:04equal to A and this entire thing
- 8:07to be equal to
- 8:09B.
- 8:10Or you have to first see the conditional
- 8:11probability apply to the rule.
- 8:13So, I can write this again as So, I make
- 8:16it equal to the conditional probability.
- 8:17So, I will write equal to
- 8:19A, which is this big term
- 8:22multiplied by I will write probability
- 8:25of
- 8:27X2
- 8:28given
- 8:30X3 {comma} X4
- 8:33XN {comma} CK.
- 8:36Or you have to write down the
- 8:37probability of you know B. So, we will
- 8:39write
- 8:41X3
- 8:43X4
- 8:44XN {comma}
- 8:47CK.
- 8:48Right? I don't know what you think this
- 8:49term will become. I can say something.
- 8:51Let's call it B. So, you put all these
- 8:53together and you get A.
- 8:54AB
- 8:56probability of
- 8:58X3 X4
- 9:01XN {comma} CK.
- 9:10Um
- 9:12chain
- 9:14rule
- 9:16for conditional probability.
- 9:18A term here mathematical
- 9:21to be honest, machine learning with my
- 9:22company I get it down. But you have to
- 9:24keep learning and understand what I
- 9:26mean. So, this is known as chain rule
- 9:28for conditional probability. I will
- 9:29probably break it down. Okay? So, don't
- 9:31you think there will be a time when
- 9:33eventually you will get it down? So, you
- 9:35have to get it down.
- 9:37So, there will be this term multiplied
- 9:38by this term and then I will say will be
- 9:40this
- 9:40multiplied by this term
- 9:48probability of
- 9:50X N given C K
- 9:54or B K C K
- 9:59C K
- 10:02X C
- 10:03X
- 10:04X N C K B and I got X N C A 1 J X N B 1
- 10:08J C
- 10:10This will become This is This will
- 10:12become the last A and this will become
- 10:16the last B
- 10:18So, many of you last minute condition
- 10:19probability that I got
- 10:21So, and then
- 10:24space for a comment, but I'll try. So,
- 10:29It's a busy day.
- 10:31So, this entire term will be simplified
- 10:32as this. P of X 1
- 10:35given
- 10:36X 2 {comma} X 3
- 10:39X N
- 10:41{comma} C K
- 10:43multiplied by
- 10:46P of
- 10:48X 2
- 10:50given X 3 X 4
- 10:54X N C K
- 10:57multiplied by
- 10:59P of X 3
- 11:01X 4
- 11:03X 5
- 11:04C K or something
- 11:09P of X N minus 1
- 11:13X N {comma} C K
- 11:18probability of X N given C K or last
- 11:23minute probability of
- 11:25C K So, this will be the entire term.
- 11:28Okay. So,
- 11:31but
- 11:34If you you'll be able to understand
- 11:36Now comes this part. John
- 11:39naive assumption
- 11:42simple assumption
- 11:44So
- 11:45Yeah
- 11:46assumption
- 11:47Yeah
- 11:50Yeah
- 11:52last terms problem
- 11:55I'm
- 11:55terms assumption
- 11:57So assumption be this
- 12:04So
- 12:05This is like this. Imagine key
- 12:09So
- 12:10So
- 12:11Let's say.
- 12:15same problem
- 12:17toss
- 12:19Mumbai
- 12:21or sunny
- 12:24Okay. So Yeah
- 12:27probability of
- 12:30a toss being lost given
- 12:35venue is Mumbai
- 12:37a
- 12:38outlook is sunny
- 12:41or match
- 12:42They
- 12:43Similarly
- 12:44Yeah So
- 12:47probability of Mumbai given outlook
- 12:51sunny or
- 12:52match you got Okay. I
- 12:55last notice
- 12:56is probabilities about coming Yeah zero
- 13:01You
- 13:02probability about Okay. So what do we
- 13:05take an assumption.
- 13:06Okay. And that assumption is this. Key
- 13:10Yeah
- 13:11X3 Q depend
- 13:16Yeah X1
- 13:17X3 depend
- 13:19Yeah
- 13:20depend
- 13:22Similarly
- 13:23X2 will not depend X3 X4
- 13:26It will only CK.
- 13:29This n minus will not depend on Xn. It
- 13:32will only depend on CK. This is the
- 13:34assumption.
- 13:40We call this assumption,
- 13:42if I remember it correctly, it's called
- 13:44conditional
- 13:49conditional
- 13:51independence.
- 13:56Independent events, so independent
- 13:58events, if you remember,
- 14:03If you condition here, P of A given B is
- 14:06equal to P of A, then these events are
- 14:08known as
- 14:09independent events. Conditional
- 14:11independence here is given by the term
- 14:13here.
- 14:17This is comma, which means intersection.
- 14:22You have conditionally
- 14:24A
- 14:25B C independent. So, we can write it
- 14:27like this, P
- 14:29A
- 14:32C.
- 14:40So, we are going to
- 14:41we are going to
- 14:43simplify this entire equation and we'll
- 14:46write this. Now,
- 14:47so this entire thing will become
- 14:51this.
- 14:52Probability of
- 14:54X1
- 14:56given CK
- 14:58probability of X2
- 15:01given CK probability of X3 given CK dot
- 15:06dot dot probability of Xn given CK
- 15:11multiplied by probability of
- 15:13CK.
- 15:14And if you remember, in the last video
- 15:16we did that.
- 15:17We did the probability of
- 15:20toss given one, probability of windy
- 15:22given one, probability of outlook given
- 15:24one. Okay, I'll multiply
- 15:27probability of winning ticket. So, yeah,
- 15:29final formula ticket. Or this may humble
- 15:33is called simplify
- 15:35mathematically. We can write this down
- 15:37as so I'm going to calculate you got to
- 15:39get them.
- 15:41Right, you got to get them.
- 15:42So, we'll write it like this.
- 15:44Probability of
- 15:47CK
- 15:49given a particular X is equal to
- 15:53probability of
- 15:56CK
- 15:59product of
- 16:01I is equal to
- 16:03one say and up probability of
- 16:07X of I
- 16:09CK. Ticket. Summation means product is
- 16:13going to inside the
- 16:14product multiplication
- 16:16ticket. So, this is the final formula.
- 16:21Ticket.
- 16:22So,
- 16:23uh this is the final formula.
- 16:25I was a classy
- 16:27or we get it
- 16:28to final decision making that
- 16:30by the way
- 16:32uh
- 16:33I'll just write it down over here so
- 16:35that clarify that.
- 16:36So,
- 16:38uh yeah.
- 16:39This is the final formula that we have
- 16:41established or derived.
- 16:43Uh
- 16:43I'll write it down again. So, this is
- 16:45the final formula. Probability of
- 16:48CK given
- 16:50X is equal to
- 16:54probability of CK
- 16:59product
- 17:00I one to N
- 17:03probability of X of I given CK, right?
- 17:08What I wanted to tell you is
- 17:10yeah, actually
- 17:12you will
- 17:13be remember from the denominator
- 17:16consider
- 17:17so I will equal to
- 17:19we have to do it
- 17:47You actually use
- 17:49arc max
- 17:52for K in the range of 1 {comma} 2
- 17:55{comma}
- 17:56small K
- 17:57and
- 17:58it is
- 18:00P of
- 18:01C K
- 18:03product of
- 18:05I is equal to 1 to N
- 18:08or probability of
- 18:10X of I C of K
- 18:27maximum
- 18:32a posteriori rule
- 18:37Yeah, map people this cool.
- 18:40maximum a posteriori rule
- 18:43Okay. So basically
- 18:53I don't know if you know but I would
- 18:55recommend
- 18:58or
- 18:59surely
- 19:04So thank you for watching.
About this transcript
This page contains the full transcript of Naive Bayes Classifier | Part 7 | Mathematics behind Naive Bayes Algorithm by CampusX, generated from the public captions YouTube serves with the video. The transcript has 1,738 words across 436 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.