Hello.
Welcome back.
In this lesson we agreed to write the function to perform the predictions.
I'm going to save what we have and stuff from a new one.
Call this number six right.
So I'm going to just jump straight in.
I'm going to come over here and create a new function called predict very simple and this function is
going to take that weight the bias and then the inputs.
So I said def it's gonna be predict and we passed W B and then X over here and what we want to do is
we can predict with multiple inputs.
We don't need to pass a single image we can pass a set of images.
So we've got to check how many images we have to do that.
I'm simply going to see a m course X door shape like we did earlier.
Index 1.
Okay.
Once that is done we can.
I'm gonna see why prediction of course and Peter zeros simply going to initialize this and pedo zeros
and then the dimension
one by M number of examples or number of input images.
And once that's done
we can simply we can simply compute for a cause like we did before sigmoid basically the m the weight
and the biases of our model will be stored and we're going to take what we get from the land function
remember the land is going to give us the weight W and then be the parameters we're going to use those
we're going to pass those to this predictive function and if we pass those to this predictive function
and we pass a y input we expect it to be able to distinguish cuts from non cuts essentially so we're
going to go through the same method we have a single activation so overhand to predict function is going
to be a single activation as well so I'm going to say N.P. dot
then wait transpose come off X plus bias so it equals sigmoid P do it way to transpose bias Okay I have
a typo here this is small W then X here is cut to X so that should be fine right.
Once that is done we've got to convert the um the activations to zero once remember the activation is
just it's just a floating point number we can end up with a value such a zero point eight zero point
nine zero point two zero point one we're going to see if the values above zero point five it means it's
a cut if it's below then it's not a cut.
So we basically convert into the probability to a binary resource an accurate prediction 0 1.
So I'm gonna come here and convert all of them at once using a loop for I in range
and the range I want here is a dot shape plus one here which is the same as M we could have you know
then I'll say if a 0 I if this is less than or equal to zero point five then why prediction where we
gonna store results or a prediction.
Zero I equals zero mean it's not a cut
else
why prediction
zero.
I of course won right.
Meaning it is a cut.
What we're gonna do now is return our y prediction.
So I'm simply going to see a return
y prediction here like this.
Okay so now we have all the functions we need in the next lesson and we're going to put the function
is to get us starting from the initialization through the propagation and then the land function we're
gonna put those together and create a new function known as the model.
And this is going to be the one that we call to train our model and get our results from it.
Okay.
So that's all there is for this lesson if you have any questions just let me know and I shall see you
later.
And if you're finding it useful just take some time off to leave a review.