1 00:00:00,382 --> 00:00:04,272 [MUSIC] 2 00:00:04,272 --> 00:00:06,618 So we're decreasing the font and 3 00:00:06,618 --> 00:00:10,980 we're gonna train a basic model on this data set. 4 00:00:10,980 --> 00:00:15,890 So the first thing I am going to do is not use the pictures but 5 00:00:15,890 --> 00:00:18,050 just use the pixels of the images and 6 00:00:18,050 --> 00:00:21,400 train a classifier on the pixels of the images and see how well that does. 7 00:00:21,400 --> 00:00:25,625 So let's just go ahead and do it. 8 00:00:25,625 --> 00:00:33,119 So #Train a classifier. 9 00:00:33,119 --> 00:00:34,420 I misspelled it here. 10 00:00:34,420 --> 00:00:39,248 So #Train a classifier on 11 00:00:39,248 --> 00:00:43,420 the raw image pixels. 12 00:00:45,410 --> 00:00:49,790 So these are going to be my features, the raw image pixels, not those deep features. 13 00:00:49,790 --> 00:00:54,306 And so I'm going to call this the raw, sorry, 14 00:00:54,306 --> 00:01:01,400 raw_pixel_model. 15 00:01:01,400 --> 00:01:04,480 And the classifier I'm gonna use, I could use any classifier. 16 00:01:04,480 --> 00:01:06,280 The performance would be about the same. 17 00:01:06,280 --> 00:01:08,200 I'm gonna use logistic regression, 18 00:01:08,200 --> 00:01:12,730 which is what we use also in the sentiment analysis notebook. 19 00:01:12,730 --> 00:01:16,480 And so in logistic regression, we're gonna give it a data set. 20 00:01:16,480 --> 00:01:18,270 So this is gonna be the training data set. 21 00:01:20,730 --> 00:01:22,960 This is my image_train. 22 00:01:22,960 --> 00:01:26,030 I'm going to tell it what the target is. 23 00:01:27,560 --> 00:01:31,790 So the target is a column in this data set called label. 24 00:01:31,790 --> 00:01:36,440 And that column has the label for each image. 25 00:01:37,710 --> 00:01:41,260 And I'm going to tell it what features to use. 26 00:01:41,260 --> 00:01:48,410 So in this case, the features are a column called image_array. 27 00:01:48,410 --> 00:01:51,793 And so I'm gonna run this. 28 00:01:51,793 --> 00:01:55,400 Wait, I must misspell, module, oh yes, 29 00:01:55,400 --> 00:01:59,720 I forgot one thing and you should have reminded me. 30 00:02:01,110 --> 00:02:05,470 In GraphLab Create, the verb that you do to create the model is create. 31 00:02:05,470 --> 00:02:07,747 So GraphLab the logistic regression, 32 00:02:07,747 --> 00:02:11,400 logistic_classifier.create creates that classifier. 33 00:02:11,400 --> 00:02:13,710 So now, it should execute. 34 00:02:13,710 --> 00:02:17,546 So we're using the raw image pixels to build a classifier. 35 00:02:17,546 --> 00:02:22,470 And just as a quick review, I don't expect that to be very good. 36 00:02:22,470 --> 00:02:24,670 But let's go ahead and do it. 37 00:02:24,670 --> 00:02:27,400 It just is done, right now. 38 00:02:29,360 --> 00:02:33,890 So let's see how it performed. 39 00:02:33,890 --> 00:02:37,850 So the first thing that I'm gonna do is just make a prediction with the model. 40 00:02:39,030 --> 00:02:44,736 So let's #Make a prediction with 41 00:02:44,736 --> 00:02:51,039 the simple model based on raw pixels. 42 00:02:53,941 --> 00:02:57,698 So I'm gonna take some images from the test data set, and 43 00:02:57,698 --> 00:03:01,450 I'm gonna see what the classifier says they are. 44 00:03:01,450 --> 00:03:07,880 So I'm gonna say image_test, and let's look at the first three images. 45 00:03:07,880 --> 00:03:11,940 So images 0:3 goes images 0, 1, and 2. 46 00:03:11,940 --> 00:03:16,930 And I'm just gonna look at those images. 47 00:03:16,930 --> 00:03:22,358 And I'm gonna type .show() on them just to show you what those images are. 48 00:03:22,358 --> 00:03:24,656 So here we are. 49 00:03:24,656 --> 00:03:31,420 The images, as I said, are a little bit small on the data set. 50 00:03:31,420 --> 00:03:37,140 But I'm gonna make this bigger so you can see, the images here are a cat, 51 00:03:37,140 --> 00:03:39,250 a car, and another cat. 52 00:03:39,250 --> 00:03:40,340 So two cats and a car. 53 00:03:40,340 --> 00:03:41,390 Car, cat, no. 54 00:03:41,390 --> 00:03:42,880 Cat, car, cat. 55 00:03:42,880 --> 00:03:49,780 And so, I'm just gonna leave the font big so we can actually see the results. 56 00:03:49,780 --> 00:03:53,170 So now, let's look at the labels for this image. 57 00:03:53,170 --> 00:03:55,510 So this is the test data. 58 00:03:55,510 --> 00:04:01,570 And this is elements 0 through 3, so the first one, three. 59 00:04:01,570 --> 00:04:06,910 I visually said it was cat, car, cat, but let's see what the actual labels are. 60 00:04:06,910 --> 00:04:14,320 So, the label column and you'll see it is cat, automobile, cat. 61 00:04:14,320 --> 00:04:17,330 So it's automobile, not car, but same thing. 62 00:04:17,330 --> 00:04:21,632 Okay so let's see what this 63 00:04:21,632 --> 00:04:26,700 raw_pixel_model predicts. 64 00:04:26,700 --> 00:04:32,345 So let me see what it predicts for this data set of three images. 65 00:04:32,345 --> 00:04:39,400 So the image_test of 0:3. 66 00:04:39,400 --> 00:04:43,810 So the truth is cat, automobile, cat and it predicts bird, cat, bird. 67 00:04:43,810 --> 00:04:47,355 So it gets all three wrong, thinks the cat is a bird, 68 00:04:47,355 --> 00:04:52,030 it thinks that car is a cat and thinks the other cat is also bird. 69 00:04:52,030 --> 00:04:56,520 So, it got all wrong, but this is only kind of a fluke qualitative thing. 70 00:04:56,520 --> 00:04:59,880 It could be that just the first few images it got wrong, so 71 00:04:59,880 --> 00:05:02,870 let's take a look at what the actual predictions are. 72 00:05:04,300 --> 00:05:07,990 So, let's evaluate the model of the test data and 73 00:05:07,990 --> 00:05:12,710 see what the actual classification accuracy is. 74 00:05:12,710 --> 00:05:18,524 So, #Evaluating raw pixel model on test data. 75 00:05:18,524 --> 00:05:24,717 So I'm going to take this raw_pixel_model and 76 00:05:24,717 --> 00:05:28,946 I'm going to call evaluate, and 77 00:05:28,946 --> 00:05:33,628 what evaluate does is it just goes and 78 00:05:33,628 --> 00:05:40,576 computes some of those errors, those error metrics, 79 00:05:40,576 --> 00:05:44,673 and I'm gonna use the test set. 80 00:05:44,673 --> 00:05:51,349 And here you see the accuracy is only 46.8%. 81 00:05:51,349 --> 00:05:52,720 It's terrible. 82 00:05:52,720 --> 00:05:57,280 You have four classes, random guess is 25%, they're balanced. 83 00:05:57,280 --> 00:05:59,570 Here it gets 46%, not that exciting. 84 00:06:00,660 --> 00:06:03,670 So there's more details there. 85 00:06:03,670 --> 00:06:05,670 The confusion matrix gets plotted. 86 00:06:05,670 --> 00:06:09,594 I'm not gonna go through that, but at home you can explore those a little bit more. 87 00:06:09,594 --> 00:06:11,312 But just remember 46%. 88 00:06:11,312 --> 00:06:14,929 [MUSIC]