All righty.
So now we've got all of our training image file names room but these are just file names at the moment
so all file paths probably the better way to do it.
I've called this phone and so we'll just leave that there.
So these are file paths to our training images which means later on we'll have a way to access them.
So it's important to note here that these are just strings.
They're not the actual images just yet.
Well we'll do that in a second.
But what we're doing now is we need to get our labels ready.
So these are our labels we've just dealt with the file I.D. and turn them into file parts.
But let's now get our labels.
So remember the premise of machine learning is to turn our data into numbers more specifically when
we're working with tensor flow.
It's to turn it into tenses.
That's what we're moving towards in this little subsection at the moment.
All right a little bit of text here since we've now got our training image file paths and a list let's
prepare our labels okay.
We've got all our labels in labels CSB.
Let's just have a look at them actually.
Let's go labels.
Let's just create a variable called labels CSA grade.
Keep it simple you know what is this come out at
OK.
So that's day type object.
Remember we have to start turning these into numbers.
So we might turn them into a num pi array.
So import num pi as.
Now I wonder if I could just do this otherwise I know another way to do it.
And what if we go labels
wonderful how many are in that Len labels 10000 turn 22 which is amazing.
The other way I was going to do it is if we comment out this I'm doing command slash that's all you
can come in out a whole line and then we go to num pi nice simple method empanadas.
Same thing
does same thing as above.
Little trick there.
Let's do the same thing as before.
Compare the amount of labels to the number of file names.
If we come back to here after we've downloaded this and unzipped it into our car lab notebook what we're
doing here is by comparing the number of labels to the number of file names checking for missing data.
So here Rambo back in the previous projects with structured data there were some cells in the data frame
that were missing but checking it with unstructured data if there's missing data is a bit harder.
So this is kind of the work around we're doing check if number of labels matches the number of phone
hands and we're just going to do the exact same as before.
So if len labels to the length of labels what we just did there equals Len file names because what we're
eventually going to have to do is pair up these labels with these file names like what we've just done
here.
So index nine thousand is Tibetan mastiff and its file name nine thousand.
Is this absolute lie and of a dog so let's go here predate a little confirmation for ourselves number
of labels matches number of file names be a uniform else print number of labels does not match number
of phone names check data directories fingers crossed.
Beautiful.
That's what we're after.
Number of labels matches number of file names.
OK now finally since a machine or not really finally we're still going a lot to go with this project.
So it's a machine learning model can't take strings as input.
This is what labels currently is right.
It's an array of strings.
What we have to do is convert it into numbers how might we do this or to begin let's find a list of
all the unique dog rates of this ten thousand two hundred twenty two in here.
But how would we find the unique labels.
So let's do this.
Find the unique label values.
So I want you to have a little think about this.
If you have an umpire Ray I'm giving you a little hint how might you find the unique values in a given
array using num high Java level.
Think you could even look it up.
There's a good Google search for that.
So NPR unique is how we find find the unique elements of an array and now this is pretty cool with collab
right.
It just pops up this dock string without me even doing anything.
So we want to find the unique labels.
Let's find that unique breeds
let's have a look at that Alton It's all right.
There's a whole bunch of different dog breeds so let's have a look at him.
Brittany spaniel never even heard of that Chihuahua.
Gordon setter Great Dane.
Yeah he's a beast.
Okay.
Getting distracted by dogs.
And so this should be 120 wonderful.
So that is because we have
120 breeds of dogs we're lining up here right.
We're getting our data ready we're getting it prepared to get into tenses.
We've only got two arrays of strings.
How might we turn these into numbers.
Why don't we turn it into an array of ball lanes.
Let me give you an example rather than talk about it.
So turn a single label into an array of ball lanes print labels zero.
Just use label zero as an example so labels zero.
Now we're going to use that comparison operator to compare the first label to unique breeds.
And what this should return is an array of true and false values where everywhere and unique breeds
labels zero doesn't equal it should be false but the only location where it does equal should be true.
There we go.
Let's have a look at these sets of Boston ball.
But then if we have a look at unique breeds
so we can say True is here so what's that about twelve in so if we go through here.
Can a map if you can Adam up you'd find Boston bull.
There we go.
True.
That's what we're after.
Let's do that for every single label so turn every label into a bull in a right if you're looking at
this and this is just all truths and falsehoods.
You're probably wondering how is this going to be converted to numbers.
But we'll see in a second as a special thing with nut pie raisin and boolean values.
So let's go bowling.
Labels equals label we'll do another list comprehension here.
So label equals unique grades for label in labels.
Let's see what the code says first.
Then we'll talk through it.
If in doubt run the code wonderful and bullying labels should be 10000 long or ten thousand two hundred
twenty two whatever it was
wonderful.
So that means we've turned every single label into a boolean label now.
What is this little this comprehension doing.
All it's doing is a scout up version of what we've got here.
So it's saying do this little one off example for every label in labels and if we remember Len labels
is ten thousand two hundred twenty two because we have ten thousand two hundred twenty two labels.
So it's done it for every single label.
He might be thinking again why are we turning him into true and false wealth.
How we can convert these boolean arrays into numbers more specifically one hot encoded numbers.
So if in doubt run the code let's check out the code then we'll talk it through.
So example turning boolean array into integers print label 0.
We'll get the first one.
So this is the original label straight from the diaphragm straight from label CSA print NDP where unique
grades equals labels.
0 print.
So actually we should probably tell this is the index where label occurs and then we're gonna go print
boolean labels 0 dot org Max.
So this is index
where label occurs in boolean array and then we're gonna go print boolean labels
as type int so there will be a one or there should be a one where the sample label occurs as a big self
but we're gonna check it out.
Look at that.
So the original label is Boston Bill and it appears at the 19th index which is the same in our boolean
labels zero index so it appears at 19.
And if we were to count this so 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 is where one occurs.
So now every single label in bullying labels is actually in this type of format so there's a one where
the actual label occurs.
So if we did the same thing for let's go to and then print labels to
is Pekinese occurs right down here and zero for everything else.
Wonderful.
So now we've got our labels in a numeric format and our image file paths easily accessible because remember
we've got file names.
These our image paths they aren't numeric yet but we can do that later on using tensor flow.
So now we've got our data in an accessible format.
Let's create some training and validation sets because if we come to our files we notice when we download
it from Kaggle we only have a train and test set to do our experiments.
We want to split our data into training and validation.
So that's what we're doing there in the next video.