YouTube2Text

Naive Bayes Part 9 | Handling Numerical Data — Transcript

by CampusX · 1,206 words · 173 segments · language en · Watch on YouTube

Full transcript

  1. 0:01So hi, if we've noticed so far,
  2. 0:02whenever we talk about Naive Bayes, we
  3. 0:05are continuously talking about
  4. 0:07categorical data. Right? In all the
  5. 0:09examples we did in the previous videos,
  6. 0:12every column was categorical. So, if
  7. 0:15instead of a categorical column, we
  8. 0:18have a numerical column, how will our
  9. 0:20Naive Bayes work? That's what we will
  10. 0:23see in this video. Okay? So let's say I
  11. 0:26have this data. There are three columns
  12. 0:29: height, weight, and gender. Height is
  13. 0:31in centimeters, weight is in pounds,
  14. 0:33and gender is male or female. Alright?
  15. 0:36So this is the input I have as data.
  16. 0:41And now my task is to create a
  17. 0:43predictor, a machine learning model,
  18. 0:45which can predict the gender of a new
  19. 0:47incoming data point. Like, if I am
  20. 0:51asked, if the height is 185 and the
  21. 0:54weight is 170, then I have to find out
  22. 0:57what the gender of this human being is.
  23. 1:00Or what is the gender of this person?
  24. 1:01Alright? So this is the problem
  25. 1:03statement, and again, we are going to
  26. 1:05use Naive Bayes. So, let's formulate
  27. 1:08the problem first. So, obviously, if
  28. 1:11you want to find out, if you have to
  29. 1:14formulate this, you have to basically
  30. 1:17find out the probability of this guy or
  31. 1:20girl being a male given height is equal
  32. 1:23to 185. And this is intersection weight
  33. 1:30is equal to 170. We have to find this.
  34. 1:34Right? And by the formula, you already
  35. 1:39know, to calculate this, you will have
  36. 1:43to find the probability of h = 185
  37. 1:47given male, multiplied by the
  38. 1:51probability of weight = 170 given male,
  39. 1:56and then you have to find the
  40. 1:59probability of being male. Right? We
  41. 2:03will have to calculate these three
  42. 2:05things. We have to calculate three
  43. 2:06probabilities. Similarly, we will also
  44. 2:09have to find out the same thing for
  45. 2:12being female. Right? So this is known.
  46. 2:15Alright? Now we have to find this, this
  47. 2:18, and this. To be honest, if you talk
  48. 2:21about this term. It is very simple.
  49. 2:25What is the probability of male? In my
  50. 2:26data. So you can see there are a total
  51. 2:28of eight data points, out of which four
  52. 2:30are male. So this will directly be 1/2.
  53. 2:34This is 1/2 directly, right? The rest
  54. 2:37is to find this and this, right? In
  55. 2:40categorical data, it's easy, right? We
  56. 2:43would separate and count them, but here
  57. 2:46you can notice that 185 is not anywhere
  58. 2:48in my entire data point. So if I have
  59. 2:51to find the probability of height, that
  60. 2:53means, basically, now I just have to
  61. 2:55focus on these four data points. In
  62. 2:58this, I want to ask, what is the
  63. 3:00probability of the height being 185
  64. 3:02among these four? If you focus on these
  65. 3:04four, on the height, there is not a
  66. 3:06single data point whose probability is
  67. 3:08185, so obviously this term will become
  68. 3:10zero. Right? Similarly, this term will
  69. 3:12also become zero and then this entire
  70. 3:13probability will become zero. So what
  71. 3:15is the solution for this? You take an
  72. 3:17assumption. Okay? So, the assumption is
  73. 3:21this, the assumption is that the height
  74. 3:28is a Gaussian distributed random
  75. 3:37variable. This is the assumption. Okay?
  76. 3:43So, what are we assuming? That ignore
  77. 3:46the female part for now. Okay? Ignore
  78. 3:48the female ones. Let's focus on the
  79. 3:50male. So here, we will assume that
  80. 3:55these four data points, these four data
  81. 3:57points, they follow the normal
  82. 3:59distribution. I hope you remember the
  83. 4:04normal distribution, this distribution,
  84. 4:06we will assume that this is a normal
  85. 4:09distribution. Okay? Now what we will do
  86. 4:13is we will first calculate the mean and
  87. 4:19standard deviation of these points,
  88. 4:21wherever there is a male, for those
  89. 4:24data points on the height column, I
  90. 4:26will find out the μ and σ, right,
  91. 4:28which is the standard deviation. Okay?
  92. 4:32Now I know this, I, I am removing this.
  93. 4:35We already know the formula for normal
  94. 4:40distribution to find out the
  95. 4:43probability of a particular data point
  96. 4:48happening is this 1/σ √2π e to the
  97. 4:56power -1/2 (x-μ/σ) whole square.
  98. 5:05Right? Now in this equation, if you see
  99. 5:09, if I have μ, as in I have the mean,
  100. 5:12and I have σ, as in I have the
  101. 5:15standard deviation, and I have x, which
  102. 5:18is this number, then I can easily find
  103. 5:21out the probability of finding x. Right
  104. 5:26? It will be some probability. Right?
  105. 5:28And this is the probability that needs
  106. 5:31to be calculated. Right? We will repeat
  107. 5:35the same work on the weight column.
  108. 5:37Okay? So what will we do? Again, we
  109. 5:39will assume that the weight column is
  110. 5:42also normally distributed. Okay? Again,
  111. 5:46we will find the μ and σ for this
  112. 5:48column wherever the gender is male.
  113. 5:51Okay? As soon as this comes, we will
  114. 5:53again put these three things into this
  115. 5:55formula. μ, σ, and x, right? And we
  116. 6:00will again get the probability of
  117. 6:02finding 170 in this data. Right? And
  118. 6:05then we will put it here. And we will
  119. 6:09multiply these three terms. We will get
  120. 6:11some probability, let's say. And
  121. 6:14similarly, we have to do the same work
  122. 6:16for the female. Exactly the same. So
  123. 6:21the only difference this time around
  124. 6:23would be. The only difference will be
  125. 6:27that now you focus on the data below,
  126. 6:28where it's female. Again, you will
  127. 6:31assume it's normally distributed. You
  128. 6:33calculate μ and σ. You calculate this
  129. 6:35value, put it here, okay? And same with
  130. 6:37this one, Right? And that is how it is
  131. 6:43done, okay? Now you might have this
  132. 6:46doubt, you could ask, but what if this
  133. 6:49assumption is wrong and it's not
  134. 6:51normally distributed, right? So, by the
  135. 6:55way, the technique we just used, we
  136. 6:57call it Gaussian. Gaussian Naive Bayes.
  137. 7:04In Scikit-learn, there is a class for
  138. 7:06this directly, you can use it directly,
  139. 7:08okay? Yeah, so coming back to your
  140. 7:10question, you can have this question
  141. 7:12that, what if this data is completely
  142. 7:14different from normal, or not normal at
  143. 7:16all, okay? In that case, what can you
  144. 7:19do? To be honest, the right approach
  145. 7:22would be to first plot the distplot to
  146. 7:24check how the data is distributed.
  147. 7:27Right? And then you can change your
  148. 7:29assumptions. You can either go with
  149. 7:32Gaussian Naive Bayes. If you feel it's
  150. 7:35close to normal. If it's not, there are
  151. 7:38various other distributions. It could
  152. 7:42be binomial. So you will use the
  153. 7:46binomial formula. And you call it
  154. 7:51binomial like this. Or you can use the
  155. 7:53Multinomial Naive Bayes. You can also
  156. 7:59use the Complement. Naive Bayes, right?
  157. 8:04So for different distributions, you
  158. 8:06will know the formula for each because
  159. 8:08everyone has a formula. You just have
  160. 8:11to find out the distribution and you
  161. 8:13just have to see which one it is close
  162. 8:14to. And then, by applying that
  163. 8:17particular distribution's formula, you
  164. 8:20can apply Naive Bayes. Right? That is
  165. 8:22the correct approach. But since it was
  166. 8:25easy to explain, I explained the entire
  167. 8:27thing using Gaussian Naive Bayes. Okay?
  168. 8:30So I hope this whole video is clear.
  169. 8:32Now in the next video, I will take the
  170. 8:34Iris dataset. Where all the columns are
  171. 8:37numerical and I will demonstrate
  172. 8:38applying these same steps on it. Okay?
  173. 8:42So thanks for watching.

About this transcript

This page contains the full transcript of Naive Bayes Part 9 | Handling Numerical Data by CampusX, generated from the public captions YouTube serves with the video. The transcript has 1,206 words across 173 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 choose a caption track available on the video.

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, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.