Okay now we've got some of the foundations of num pi down pat.
Or maybe not.
It's all right.
You don't have to know anything up by heart.
For now let's look at a little practical example to finish things off.
Practical example now I'm pi in action.
Play of 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.
Now got some photos in here.
So the whole premise.
Remember we talked about it right at the start with none pi 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 happened 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.
Stoat.
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 non pi array because
once we've turned this image into an umpire Ray 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 mapped Gottlieb we're going to see map pop live in another section import in red.
So this is just a little little package within map plot lib called M Reed which stands for image read.
This is going to do is m read might use our shift tab to figure this out.
Or 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 today f name stands for file name I believe.
String or file like the image file to read.
Wonderful.
Now Pan that image is in the file images under pan and up Pan G so we can pass it a string here.
Panda dot P. J.
What we might do is before we even look at it let's check what type it comes in panda we forgot the
images folder.
That's right.
Class num pi and you're right.
Yes.
Now what does that mean.
Well it means because it's an empty array format we can use all of the functionality that we've learned
about num PI on this array.
So let's have a look at it.
Panda wow is a lot of numbers there.
Let's check out some of the attributes of its size.
Panda don't shape panda don't.
And dim This is pretty big.
What's that number.
Twenty four million four hundred and sixty five thousand.
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 100 to these numbers here.
Maybe that's even too many.
They want to view the first five There we go first five.
What this is done is a little function im read I m Reid 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 to see a single pixel That's 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 disarray.
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 gonna do is you're going to a car equals M read that same images car photo dot P G wonderful.
We're going to check it again just for completeness type car.
Now apply Ray beautiful so now we've turned this car photo into an endless array.
Wonderful.
Okay.
I you just only see the first section of that let's have a look at one more photo to.
It goes in read the images we've seen this dog photo before right at the start.
My beautiful poppies.
We're gonna turn them into numbers.
Actually we want to view it first.
So we'll go to source equals images dog photo if you have a pen.
Image this raid function will work with with urine so you could try that to start using it.
You just need to run this for Matt pop live in Port and Reed then you can use this.
Remember to use shift tab if you want to figure out what it does turn this into marked down there's
my beautiful poppies that's 7 that's Bella.
So we're gonna turn the poppies into can you guess what data type num pi array.
Wonderful.
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
learning as we turned our data into numbers specifically a num pi array.
So what a machine learning algorithm would do is because it can't really look at this.
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.
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 OK.
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 so that's going
to wrap up the NUM pi 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 name pi library.
The biggest thing is that num pi 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 num Pi.
And if you don't understand everything right now that's okay.
There's a lot to take him have a break.
Play around with some of your own images.
Try and turn them into num pi arrays go back through what we've covered and I'll see you in the next
section.