1 00:00:00,330 --> 00:00:05,580 Okay now we've got some of the foundations of num pi down pat. 2 00:00:05,580 --> 00:00:06,340 Or maybe not. 3 00:00:06,340 --> 00:00:06,740 It's all right. 4 00:00:06,750 --> 00:00:07,980 You don't have to know anything up by heart. 5 00:00:07,980 --> 00:00:13,320 For now let's look at a little practical example to finish things off. 6 00:00:13,320 --> 00:00:18,530 Practical example now I'm pi in action. 7 00:00:18,750 --> 00:00:22,030 Play of the beautiful action music a beautiful wrong word. 8 00:00:22,050 --> 00:00:22,670 Let's go. 9 00:00:22,680 --> 00:00:23,880 Intense action music. 10 00:00:23,880 --> 00:00:25,470 Rock and roll. 11 00:00:25,500 --> 00:00:30,780 Now if we come back here to our Jupiter dashboard I've got a little folder here called images which 12 00:00:30,780 --> 00:00:32,060 I've just created. 13 00:00:32,160 --> 00:00:33,710 Now got some photos in here. 14 00:00:33,960 --> 00:00:34,880 So the whole premise. 15 00:00:34,890 --> 00:00:38,790 Remember we talked about it right at the start with none pi is in machine learning. 16 00:00:38,790 --> 00:00:40,950 You take whatever data you have. 17 00:00:41,010 --> 00:00:42,860 You turn it into numbers. 18 00:00:42,930 --> 00:00:46,780 You use a machine learning algorithm to find patterns in those numbers. 19 00:00:46,800 --> 00:00:52,710 So what if your data happened to be images and you wanted to find out information about those images. 20 00:00:52,720 --> 00:00:56,510 I'm going to create a little markdown cell here and import. 21 00:00:56,760 --> 00:01:00,120 I've got a panda image that we've used in the pandas section. 22 00:01:00,510 --> 00:01:05,030 So we're going to turn our wonderful panda we can see it there. 23 00:01:05,340 --> 00:01:06,050 Stoat. 24 00:01:06,090 --> 00:01:06,940 Give it a high five. 25 00:01:07,010 --> 00:01:17,200 I'm high five in the screen what we want to do is we want to turn an image into a non pi array because 26 00:01:17,320 --> 00:01:22,630 once we've turned this image into an umpire Ray then we can use the functions that we've learnt throughout 27 00:01:22,630 --> 00:01:26,380 this entire section to find patterns in that we can manipulate it a bit. 28 00:01:26,440 --> 00:01:28,800 We could pass it into a machine learning algorithm. 29 00:01:28,900 --> 00:01:31,150 The world is our oyster when our data is in numbers. 30 00:01:31,150 --> 00:01:37,330 So we have here mapped Gottlieb we're going to see map pop live in another section import in red. 31 00:01:37,330 --> 00:01:43,560 So this is just a little little package within map plot lib called M Reed which stands for image read. 32 00:01:43,660 --> 00:01:49,950 This is going to do is m read might use our shift tab to figure this out. 33 00:01:50,290 --> 00:01:52,780 Or is it going to be there. 34 00:01:52,780 --> 00:01:54,610 Maybe because we haven't imported it yet. 35 00:01:56,740 --> 00:01:58,550 We'll need something that's okay. 36 00:01:58,570 --> 00:02:01,090 We want to go shift tab. 37 00:02:01,090 --> 00:02:04,660 There we go read an image from a file into an array. 38 00:02:04,810 --> 00:02:09,890 That is exactly what we want today f name stands for file name I believe. 39 00:02:10,000 --> 00:02:12,670 String or file like the image file to read. 40 00:02:12,670 --> 00:02:14,100 Wonderful. 41 00:02:14,140 --> 00:02:23,510 Now Pan that image is in the file images under pan and up Pan G so we can pass it a string here. 42 00:02:23,820 --> 00:02:26,680 Panda dot P. J. 43 00:02:26,880 --> 00:02:34,580 What we might do is before we even look at it let's check what type it comes in panda we forgot the 44 00:02:34,580 --> 00:02:35,820 images folder. 45 00:02:35,900 --> 00:02:36,420 That's right. 46 00:02:37,860 --> 00:02:40,290 Class num pi and you're right. 47 00:02:40,800 --> 00:02:41,500 Yes. 48 00:02:41,500 --> 00:02:42,960 Now what does that mean. 49 00:02:42,960 --> 00:02:49,200 Well it means because it's an empty array format we can use all of the functionality that we've learned 50 00:02:49,200 --> 00:02:51,220 about num PI on this array. 51 00:02:51,240 --> 00:02:52,830 So let's have a look at it. 52 00:02:52,950 --> 00:02:57,510 Panda wow is a lot of numbers there. 53 00:02:58,350 --> 00:03:01,250 Let's check out some of the attributes of its size. 54 00:03:01,320 --> 00:03:05,730 Panda don't shape panda don't. 55 00:03:06,780 --> 00:03:10,680 And dim This is pretty big. 56 00:03:11,160 --> 00:03:12,150 What's that number. 57 00:03:12,150 --> 00:03:15,670 Twenty four million four hundred and sixty five thousand. 58 00:03:15,720 --> 00:03:18,050 It's got a lot of dimensions here. 59 00:03:18,210 --> 00:03:22,950 It's a three dimensional array because the three dimensions are color channels and what what this array 60 00:03:22,950 --> 00:03:28,060 actually is let's just view the first 100 to these numbers here. 61 00:03:28,170 --> 00:03:30,120 Maybe that's even too many. 62 00:03:30,300 --> 00:03:36,350 They want to view the first five There we go first five. 63 00:03:36,410 --> 00:03:43,130 What this is done is a little function im read I m Reid however you want to pronounce it has taken this 64 00:03:43,130 --> 00:03:49,580 picture and then found all of the little pixel value so if we zoomed right in here you might not even 65 00:03:49,580 --> 00:03:52,680 be to see a single pixel That's right. 66 00:03:52,700 --> 00:04:00,200 We zoomed right in here got the pixels those pixels have color values so red green and blue and that 67 00:04:00,260 --> 00:04:02,750 is what is stored in disarray. 68 00:04:02,750 --> 00:04:06,760 So if we did the same let's have a look maybe for another image. 69 00:04:06,860 --> 00:04:11,290 So we've got image source. 70 00:04:11,330 --> 00:04:17,390 We have another one images tab for auto complete car photo. 71 00:04:17,390 --> 00:04:18,190 This is what I have now. 72 00:04:18,200 --> 00:04:24,440 You can try this with your own image beautiful. 73 00:04:24,510 --> 00:04:34,320 So what we're gonna do is you're going to a car equals M read that same images car photo dot P G wonderful. 74 00:04:34,500 --> 00:04:39,120 We're going to check it again just for completeness type car. 75 00:04:40,340 --> 00:04:48,770 Now apply Ray beautiful so now we've turned this car photo into an endless array. 76 00:04:48,920 --> 00:04:50,410 Wonderful. 77 00:04:50,410 --> 00:04:51,250 Okay. 78 00:04:51,310 --> 00:04:58,400 I you just only see the first section of that let's have a look at one more photo to. 79 00:04:58,470 --> 00:05:04,590 It goes in read the images we've seen this dog photo before right at the start. 80 00:05:04,590 --> 00:05:06,150 My beautiful poppies. 81 00:05:06,360 --> 00:05:08,730 We're gonna turn them into numbers. 82 00:05:08,800 --> 00:05:10,540 Actually we want to view it first. 83 00:05:10,630 --> 00:05:18,970 So we'll go to source equals images dog photo if you have a pen. 84 00:05:18,970 --> 00:05:25,360 Image this raid function will work with with urine so you could try that to start using it. 85 00:05:25,360 --> 00:05:29,780 You just need to run this for Matt pop live in Port and Reed then you can use this. 86 00:05:29,860 --> 00:05:36,150 Remember to use shift tab if you want to figure out what it does turn this into marked down there's 87 00:05:36,160 --> 00:05:38,790 my beautiful poppies that's 7 that's Bella. 88 00:05:39,040 --> 00:05:47,160 So we're gonna turn the poppies into can you guess what data type num pi array. 89 00:05:47,240 --> 00:05:48,440 Wonderful. 90 00:05:48,440 --> 00:05:55,100 So I've got dog so now what we could do with this is we've done one of the biggest steps of all machine 91 00:05:55,100 --> 00:05:59,410 learning as we turned our data into numbers specifically a num pi array. 92 00:05:59,690 --> 00:06:04,080 So what a machine learning algorithm would do is because it can't really look at this. 93 00:06:04,280 --> 00:06:10,470 Ask people we can look at this and go that's a tree as a tree that the dog that's AIS that's a shelter. 94 00:06:11,240 --> 00:06:14,530 But what a machine learning algorithm needs is numbers. 95 00:06:14,690 --> 00:06:17,740 And that's what it's got here in the form of an umpire Ray. 96 00:06:17,780 --> 00:06:24,140 So what it would do is it could take say this tree is is this section of numbers here. 97 00:06:24,140 --> 00:06:30,260 Probably not but let's just imagine it is what it will do is then go to this image and then look at 98 00:06:30,590 --> 00:06:32,720 this section of numbers here and go Oh OK. 99 00:06:32,720 --> 00:06:34,430 Those numbers are pretty close to each other. 100 00:06:34,760 --> 00:06:41,830 So this item here in this image must be a tree and this must be some grass and then same thing in here. 101 00:06:41,840 --> 00:06:50,590 This must be some grass because the pixel values are very close together in both images so that's going 102 00:06:50,590 --> 00:06:52,780 to wrap up the NUM pi section. 103 00:06:52,780 --> 00:06:58,600 What the important takeaways from this is to remember that we have covered a lot and you don't need 104 00:06:58,600 --> 00:07:01,120 to know all of this off by heart to begin with. 105 00:07:01,120 --> 00:07:07,000 It's just I've gone through some of the major concepts and functionality of the name pi library. 106 00:07:07,000 --> 00:07:14,410 The biggest thing is that num pi handles data types like this arrays very very well. 107 00:07:14,410 --> 00:07:19,000 So if you're working with machine learning and you're working with doing mathematical operations you're 108 00:07:19,000 --> 00:07:23,540 trying to find patterns in data you're probably going to use num Pi. 109 00:07:24,100 --> 00:07:26,770 And if you don't understand everything right now that's okay. 110 00:07:26,770 --> 00:07:29,080 There's a lot to take him have a break. 111 00:07:29,080 --> 00:07:31,040 Play around with some of your own images. 112 00:07:31,060 --> 00:07:36,580 Try and turn them into num pi arrays go back through what we've covered and I'll see you in the next 113 00:07:36,580 --> 00:07:37,000 section.