﻿[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.42,0:00:04.33,Default,,0000,0000,0000,,Okay, so now what I've done is I've gone to the Gaussian Naive Bayes Dialogue: 0,0:00:04.33,0:00:05.38,Default,,0000,0000,0000,,documentation page. Dialogue: 0,0:00:05.38,0:00:08.10,Default,,0000,0000,0000,,sklearn.naive_bayes.GaussianNB. Dialogue: 0,0:00:08.10,0:00:11.45,Default,,0000,0000,0000,,This was that algorithm that I set out to find and Dialogue: 0,0:00:11.45,0:00:15.65,Default,,0000,0000,0000,,now that I've, now I've found the SK Learn documentation page. Dialogue: 0,0:00:15.65,0:00:18.41,Default,,0000,0000,0000,,So the first thing that I see right here, actually this is one of the things I Dialogue: 0,0:00:18.41,0:00:22.96,Default,,0000,0000,0000,,love about the SK Learn documentation, is it's full of examples. Dialogue: 0,0:00:22.96,0:00:25.64,Default,,0000,0000,0000,,When I was actually developing the code for this class, this was one of Dialogue: 0,0:00:25.64,0:00:28.55,Default,,0000,0000,0000,,the first things that I would always do is I would come find the example code Dialogue: 0,0:00:28.55,0:00:31.03,Default,,0000,0000,0000,,and I would try to just run in my Python interpreter, Dialogue: 0,0:00:31.03,0:00:32.55,Default,,0000,0000,0000,,see if I could get it working. Dialogue: 0,0:00:32.55,0:00:36.11,Default,,0000,0000,0000,,And almost invariably it works right out of the box. Dialogue: 0,0:00:36.11,0:00:37.57,Default,,0000,0000,0000,,So here's something that's just very simple. Dialogue: 0,0:00:37.57,0:00:39.62,Default,,0000,0000,0000,,There's only a few lines here that are really important. Dialogue: 0,0:00:39.62,0:00:41.11,Default,,0000,0000,0000,,So let me point them out to you and Dialogue: 0,0:00:41.11,0:00:45.64,Default,,0000,0000,0000,,then I'll show you the code I've actually written for the example we just saw, Dialogue: 0,0:00:45.64,0:00:48.25,Default,,0000,0000,0000,,and you'll start to recognize some of these lines. Dialogue: 0,0:00:48.25,0:00:49.18,Default,,0000,0000,0000,,But first let's introduce them. Dialogue: 0,0:00:49.18,0:00:52.43,Default,,0000,0000,0000,,So the first one that's really important is this one right here. Dialogue: 0,0:00:53.55,0:00:56.95,Default,,0000,0000,0000,,Above this it's just creating some, some training points that we can use, Dialogue: 0,0:00:56.95,0:00:57.79,Default,,0000,0000,0000,,it's not that important. Dialogue: 0,0:00:57.79,0:01:01.79,Default,,0000,0000,0000,,This is where the real meat starts, is with this import statement and if you've Dialogue: 0,0:01:01.79,0:01:04.54,Default,,0000,0000,0000,,programmed in Python before, you're well acquainted with import statements. Dialogue: 0,0:01:04.54,0:01:08.48,Default,,0000,0000,0000,,This is the way that you bring in external modules into the code that you're Dialogue: 0,0:01:08.48,0:01:12.36,Default,,0000,0000,0000,,writing so that you don't have to completely re-implement everything every time, Dialogue: 0,0:01:12.36,0:01:15.47,Default,,0000,0000,0000,,you can use code that someone else has already written. Dialogue: 0,0:01:15.47,0:01:19.38,Default,,0000,0000,0000,,So we say from sklearn.naive_bayes going to import GaussianNB. Dialogue: 0,0:01:19.38,0:01:20.35,Default,,0000,0000,0000,,Very good. Dialogue: 0,0:01:20.35,0:01:23.02,Default,,0000,0000,0000,,The next thing that we're going to do is we're going to use that to Dialogue: 0,0:01:23.02,0:01:24.21,Default,,0000,0000,0000,,create a classifier. Dialogue: 0,0:01:24.21,0:01:27.04,Default,,0000,0000,0000,,So classifier equals GaussianNB. Dialogue: 0,0:01:27.04,0:01:28.79,Default,,0000,0000,0000,,If you miss your import statement. Dialogue: 0,0:01:28.79,0:01:29.84,Default,,0000,0000,0000,,If you forget this line for Dialogue: 0,0:01:29.84,0:01:32.48,Default,,0000,0000,0000,,some reason, then this line is going to throw an error. Dialogue: 0,0:01:32.48,0:01:36.03,Default,,0000,0000,0000,,So if you end up seeing some kind of error that says that it doesn't recognize Dialogue: 0,0:01:36.03,0:01:37.57,Default,,0000,0000,0000,,this function. Dialogue: 0,0:01:37.57,0:01:40.35,Default,,0000,0000,0000,,It's probably a problem with your import statement. Dialogue: 0,0:01:40.35,0:01:42.51,Default,,0000,0000,0000,,So, okay, we've created our classifier. Dialogue: 0,0:01:42.51,0:01:45.29,Default,,0000,0000,0000,,So now the code is all sort of ready to go. Dialogue: 0,0:01:45.29,0:01:47.36,Default,,0000,0000,0000,,The next thing that we need to do is we need to fit it. Dialogue: 0,0:01:48.55,0:01:51.71,Default,,0000,0000,0000,,And we've been using the word train interchangeably with fit. Dialogue: 0,0:01:51.71,0:01:54.79,Default,,0000,0000,0000,,So this is where we actually give it the training data, Dialogue: 0,0:01:54.79,0:01:57.07,Default,,0000,0000,0000,,and it learns the patterns. Dialogue: 0,0:01:57.07,0:02:00.03,Default,,0000,0000,0000,,So we have the classifier that we just created. Dialogue: 0,0:02:00.03,0:02:03.87,Default,,0000,0000,0000,,We're calling the fit function on it, and then the two arguments that we pass to Dialogue: 0,0:02:03.87,0:02:10.00,Default,,0000,0000,0000,,fit are x, which in this case are the features and y which are the labels. Dialogue: 0,0:02:10.00,0:02:13.10,Default,,0000,0000,0000,,This is always going to be true in supervised classification. Dialogue: 0,0:02:13.10,0:02:14.74,Default,,0000,0000,0000,,Is that it's going to call this fit function and Dialogue: 0,0:02:14.74,0:02:16.40,Default,,0000,0000,0000,,then it's going to have the features. Dialogue: 0,0:02:16.40,0:02:17.19,Default,,0000,0000,0000,,And then the labels. Dialogue: 0,0:02:18.60,0:02:22.06,Default,,0000,0000,0000,,And then the last thing that we do is we ask the classifier that Dialogue: 0,0:02:22.06,0:02:24.30,Default,,0000,0000,0000,,we've just trained for some predictions. Dialogue: 0,0:02:24.30,0:02:25.47,Default,,0000,0000,0000,,So we give it a new point. Dialogue: 0,0:02:25.47,0:02:29.32,Default,,0000,0000,0000,,In this case the point is negative 0.8, negative 1. Dialogue: 0,0:02:29.32,0:02:32.88,Default,,0000,0000,0000,,And we ask for this what do you think the label is for this particular point? Dialogue: 0,0:02:32.88,0:02:35.37,Default,,0000,0000,0000,,What's the, what class does it belong to? Dialogue: 0,0:02:35.37,0:02:38.39,Default,,0000,0000,0000,,So in this particular case it says it belongs to class number one. Dialogue: 0,0:02:38.39,0:02:42.48,Default,,0000,0000,0000,,Or you could imagine for some other point it might say class number two. Dialogue: 0,0:02:42.48,0:02:47.60,Default,,0000,0000,0000,,So of course you have to have already fit the classifier before you Dialogue: 0,0:02:47.60,0:02:48.85,Default,,0000,0000,0000,,can call predict on it. Dialogue: 0,0:02:48.85,0:02:50.50,Default,,0000,0000,0000,,Because when it's fitting the data that's where it's Dialogue: 0,0:02:50.50,0:02:51.59,Default,,0000,0000,0000,,actually learning the patterns. Dialogue: 0,0:02:51.59,0:02:55.14,Default,,0000,0000,0000,,Then here is where it's using those patterns to make a prediction. Dialogue: 0,0:02:55.14,0:02:56.53,Default,,0000,0000,0000,,So, that's it. Dialogue: 0,0:02:56.53,0:02:59.38,Default,,0000,0000,0000,,That's kind of, now you know most all there is to Dialogue: 0,0:02:59.38,0:03:02.20,Default,,0000,0000,0000,,know to get this working in the first example that I've done.