‫Okay, Now we've got some of the foundations of numpy down pat.
‫Or maybe not.
‫All right.
‫You don't have to know everything up by heart for now.
‫Let's look at a little practical example to finish things off.
‫Practical example.
‫Non pi in action.
‫Play the beautiful action music.
‫A beautiful, wrong word.
‫Let's go.
‫Intense action music.
‫Rock and roll.
‫Now, if we come back here to our Jupiter dashboard, I've got a little folder here called Images,
‫which I've just created, and I've got some photos in here.
‫So the whole premise remember we talked about it right at the start with NumPy is in machine learning.
‫You take whatever data you have, you turn it into numbers.
‫You use a machine learning algorithm to find patterns in those numbers.
‫So what if your data happen to be images and you wanted to find out information about those images?
‫I'm going to create a little markdown cell here and import I've got a panda image that we've used in
‫the pandas section.
‫So we're going to turn our wonderful panda.
‫We can see it there.
‫Look at that.
‫You start.
‫Give it a high five.
‫I'm high five in the screen.
‫What we want to do is we want to turn an image into a numpy array, because once we've turned this image
‫into an umpire array, then we can use the functions that we've learnt throughout this entire section
‫to find patterns in that we can manipulate it a bit.
‫We could pass it into a machine learning algorithm.
‫The world is our oyster when our data is in numbers.
‫So we have here map plot lib.
‫We're going to see map plot lib in another section, import in red.
‫So this is just a little little package within map plot lib called M read, which stands for image read.
‫What this is going to do is m read.
‫We might use our shift tab to figure this out.
‫Well, is it going to be there?
‫Maybe because we haven't imported it yet.
‫We'll need something.
‫That's okay.
‫We want to go shift tab.
‫There we go.
‫Read an image from a file into an array.
‫That is exactly what we want to do.
‫If name stands for file name, I believe string or file like the image file to read.
‫Wonderful.
‫Now our panda image.
‫Is in the file images on the Pan Am PNG so we can pass it a string here.
‫Panda dot PNG.
‫What we might do is before we even look at it, let's check what type it comes in.
‫Panda.
‫What?
‫We forgot the images folder.
‫That's all right.
‫Class, numpy and array?
‫Yes.
‫Now, what does that mean?
‫Well, it means because it's in new era format, we can use all of the functionality that we've learned
‫about numpy on this array.
‫So let's have a look at it.
‫Panda.
‫Wow.
‫There's a lot of numbers there.
‫Let's check out some of the attributes of it.
‫Size, Panda dot Shape.
‫Panda dot and.
‫This is pretty big.
‫What's that number?
‫24,465,000.
‫It's got a lot of dimensions here.
‫It's a three dimensional array because the three dimensions are color channels.
‫And what what this array actually is.
‫Let's just view the first 200.
‫So these numbers here, maybe that's even too many.
‫They want to be the first five.
‫There we go.
‫First five.
‫What this has done is little function im read, im read however you want to pronounce.
‫It has taken this picture and then found all of the little pixel value.
‫So if we zoomed right in here you might not even be able to see a single pixel.
‫That's all right.
‫We zoomed right in here, got the pixels.
‫Those pixels have color values.
‫So red, green and blue, and that is what is stored in this array.
‫So if we did the same, let's have a look.
‫Maybe for another image.
‫So we've got image source.
‫We have another one.
‫Images tab for auto complete car photo.
‫This is what I have now.
‫You can try this with your own image.
‫Beautiful.
‫So what we're going to do is we're going to car equals M read that same images car photo PNG Wonderful.
‫We're going to check it again just for completeness.
‫Type car.
‫NumPy array.
‫Beautiful.
‫So now we've turned this car photo into an NDI array.
‫Wonderful.
‫Okay, maybe we'll just only see the first section of that.
‫Let's have a look at one more photo.
‫Dog equals M raid images.
‫We've seen this dog photo before, right at the start.
‫My beautiful puppies.
‫We're going to turn them into numbers.
‫Actually we want to view it first so we'll go OMG.
‫Source Eagles Images Dog Photo.
‫If you have a PNG image, this MB read function will work with with your own so you can try that.
‫To start using it, you just need to run this full map plot leaving port in red.
‫Then you can use this.
‫Remember to use shift tab if you want to figure out what it does.
‫So turn this into markdown.
‫There's my beautiful puppies.
‫That's seven.
‫That's Bella.
‫So we're going to turn the puppies into.
‫Can you guess what data type numpy array.
‫Wonderful.
‫So I got dog.
‫So now what we could do with this is we've done one of the biggest steps of all machine learning as
‫we turned our data into numbers, specifically in numpy array.
‫So what a machine learning algorithm would do is because it can't really look at this as people, we
‫can look at this and go, That's a tree.
‫That's a tree, that's a dog, that's eyes, that's a shelter.
‫But what a machine learning algorithm needs is numbers.
‫And that's what it's got here in the form of an umpire.
‫Ray.
‫So what it would do is it could take, say, this tree is is this section of numbers here?
‫Probably not.
‫But let's just imagine it is.
‫What it will do is then go to this image and then look at this section of numbers here and go, oh,
‫okay, those numbers are pretty close to each other.
‫So this item here in this image must be a tree and this must be some grass.
‫And then same thing in here.
‫This must be some grass because the pixel values are very close together in both images.
‫That's going to wrap up the NumPy section.
‫What the important takeaways from this is to remember that we have covered a lot and you don't need
‫to know all of this off by heart to begin with.
‫It's just I've gone through some of the major concepts and functionality of the NumPy library.
‫The biggest thing is that NumPy handles data types like this arrays very, very well.
‫So if you're working with machine learning and you're working with doing mathematical operations, you're
‫trying to find patterns in data, you're probably going to use numpy.
‫And if you don't understand everything right now, that's okay.
‫There's a lot to take in.
‫Have a break.
‫Play around with some of your own images.
‫Try and turn them into numpy arrays.
‫Go back through what we've covered and I'll see you in the next section.