0:00:00.420,0:00:04.330 Okay, so now what I've done is I've gone to the Gaussian Naive Bayes 0:00:04.330,0:00:05.385 documentation page. 0:00:05.385,0:00:08.100 sklearn.naive_bayes.GaussianNB. 0:00:08.100,0:00:11.450 This was that algorithm that I set out to find and 0:00:11.450,0:00:15.650 now that I've, now I've found the SK Learn documentation page. 0:00:15.650,0:00:18.410 So the first thing that I see right here, actually this is one of the things I 0:00:18.410,0:00:22.960 love about the SK Learn documentation, is it's full of examples. 0:00:22.960,0:00:25.640 When I was actually developing the code for this class, this was one of 0:00:25.640,0:00:28.550 the first things that I would always do is I would come find the example code 0:00:28.550,0:00:31.030 and I would try to just run in my Python interpreter, 0:00:31.030,0:00:32.549 see if I could get it working. 0:00:32.549,0:00:36.110 And almost invariably it works right out of the box. 0:00:36.110,0:00:37.570 So here's something that's just very simple. 0:00:37.570,0:00:39.620 There's only a few lines here that are really important. 0:00:39.620,0:00:41.110 So let me point them out to you and 0:00:41.110,0:00:45.640 then I'll show you the code I've actually written for the example we just saw, 0:00:45.640,0:00:48.250 and you'll start to recognize some of these lines. 0:00:48.250,0:00:49.180 But first let's introduce them. 0:00:49.180,0:00:52.430 So the first one that's really important is this one right here. 0:00:53.550,0:00:56.950 Above this it's just creating some, some training points that we can use, 0:00:56.950,0:00:57.790 it's not that important. 0:00:57.790,0:01:01.790 This is where the real meat starts, is with this import statement and if you've 0:01:01.790,0:01:04.540 programmed in Python before, you're well acquainted with import statements. 0:01:04.540,0:01:08.480 This is the way that you bring in external modules into the code that you're 0:01:08.480,0:01:12.360 writing so that you don't have to completely re-implement everything every time, 0:01:12.360,0:01:15.470 you can use code that someone else has already written. 0:01:15.470,0:01:19.380 So we say from sklearn.naive_bayes going to import GaussianNB. 0:01:19.380,0:01:20.350 Very good. 0:01:20.350,0:01:23.020 The next thing that we're going to do is we're going to use that to 0:01:23.020,0:01:24.210 create a classifier. 0:01:24.210,0:01:27.040 So classifier equals GaussianNB. 0:01:27.040,0:01:28.790 If you miss your import statement. 0:01:28.790,0:01:29.840 If you forget this line for 0:01:29.840,0:01:32.480 some reason, then this line is going to throw an error. 0:01:32.480,0:01:36.030 So if you end up seeing some kind of error that says that it doesn't recognize 0:01:36.030,0:01:37.570 this function. 0:01:37.570,0:01:40.350 It's probably a problem with your import statement. 0:01:40.350,0:01:42.510 So, okay, we've created our classifier. 0:01:42.510,0:01:45.290 So now the code is all sort of ready to go. 0:01:45.290,0:01:47.360 The next thing that we need to do is we need to fit it. 0:01:48.550,0:01:51.710 And we've been using the word train interchangeably with fit. 0:01:51.710,0:01:54.790 So this is where we actually give it the training data, 0:01:54.790,0:01:57.070 and it learns the patterns. 0:01:57.070,0:02:00.030 So we have the classifier that we just created. 0:02:00.030,0:02:03.870 We're calling the fit function on it, and then the two arguments that we pass to 0:02:03.870,0:02:10.000 fit are x, which in this case are the features and y which are the labels. 0:02:10.000,0:02:13.100 This is always going to be true in supervised classification. 0:02:13.100,0:02:14.740 Is that it's going to call this fit function and 0:02:14.740,0:02:16.400 then it's going to have the features. 0:02:16.400,0:02:17.190 And then the labels. 0:02:18.600,0:02:22.060 And then the last thing that we do is we ask the classifier that 0:02:22.060,0:02:24.300 we've just trained for some predictions. 0:02:24.300,0:02:25.470 So we give it a new point. 0:02:25.470,0:02:29.320 In this case the point is negative 0.8, negative 1. 0:02:29.320,0:02:32.880 And we ask for this what do you think the label is for this particular point? 0:02:32.880,0:02:35.370 What's the, what class does it belong to? 0:02:35.370,0:02:38.390 So in this particular case it says it belongs to class number one. 0:02:38.390,0:02:42.480 Or you could imagine for some other point it might say class number two. 0:02:42.480,0:02:47.600 So of course you have to have already fit the classifier before you 0:02:47.600,0:02:48.850 can call predict on it. 0:02:48.850,0:02:50.500 Because when it's fitting the data that's where it's 0:02:50.500,0:02:51.590 actually learning the patterns. 0:02:51.590,0:02:55.140 Then here is where it's using those patterns to make a prediction. 0:02:55.140,0:02:56.530 So, that's it. 0:02:56.530,0:02:59.380 That's kind of, now you know most all there is to 0:02:59.380,0:03:02.200 know to get this working in the first example that I've done.