‫Okay.
‫So we've seen how to make predictions using our trained machine learning model and the predict function.
‫Now let's have a look at how we can use a predict probe a function more succinctly.
‫What exactly is the predict probe function?
‫Now, what we might do is I might move this comment into a markdown cell because this will make a little
‫bit more sense and that is a function.
‫So that's going to get that.
‫And then we're going to go here and predict proba returns.
‫Probabilities.
‫Probabilities of a classification label.
‫Don't take my word for it.
‫Let's have a look at the psychic loan documentation because this is good practice.
‫So psychic.
‫Learn.
‫Predict.
‫Probe.
‫There we go.
‫Here we want.
‫Predict.
‫Probe.
‫Probability estimates.
‫The returned estimates for all classes are ordered by the label of classes.
‫Okay, so probability estimates.
‫Hmm.
‫What does that mean?
‫Scratches bid majestically.
‫Let's have a look.
‫I run the code first.
‫Predict prober.
‫What does it take?
‫If we go back to here, it takes X.
‫All right, so that's what we can do.
‫Takes X, maybe we'll pass it the test data, just like we did with predict.
‫Well, we get a lot.
‫Maybe we only want to do the first five.
‫Okay.
‫So predicts private returns.
‫The probability of a classification label now in cyclone they've used the returned estimates for all
‫classes.
‫So a class would be not heart disease and the other class would be heart disease.
‫So that's just another word for different labels classes.
‫Now, what do we have here?
‫Well, we have probability estimates now.
‫What exactly is this?
‫Let's predict.
‫On the same data.
‫So it's probably easier to understand, in contrast when we use just the normal predict function.
‫And we want the first five of test.
‫Alright.
‫So returns the probabilities of a classification label.
‫That's what we got here.
‫So if we look, let's line up this, predict probe.
‫It returns an array of five different samples, right?
‫So five.
‫This mega array here, the two and braces here contain five smaller arrays because we've used five here
‫using slicing and so does this.
‫But within this array here, there's five arrays of two numbers, but this only has one array of five
‫numbers.
‫Hmm.
‫What's happening here?
‫Well, this is what it means by returns the probabilities of a classification label.
‫So if we look at this, let's line up sample one or sample zero.
‫With this first array, we can see that the number on the left, a.k.a 0.89, is far greater than 0.11.
‫All right.
‫Now, let's see if there's a trend here.
‫We go to here, index one.
‫The label.
‫The value on the right is bigger.
‫And now this is a one.
‫Now if we go to index two, aka label one, okay, the value on the right is bigger again.
‫So that's index one of this array and then we've got zero.
‫This value is bigger.
‫And then again for the final one, it's value one.
‫And the value at index one is greater.
‫Hmm.
‫So what this is, is it's making predictions on the same data, but instead of just returning the label,
‫it's returning the probability of that label being true.
‫So remember, our labels are zero and one.
‫So if we go here heart disease target and we want value can't.
‫So we've got one for heart disease and zero for not heart disease.
‫So what predict probe R is doing is going, Hey, I'm looking at the first five rows of these.
‫So X test, I'm looking at these samples.
‫What I've learned on the training data, if I look at this sample here, I'm giving it label zero.
‫So not heart disease.
‫And I'm predicting that label zero with a probability of 0.89.
‫And so if we added these two together, like the maximum probability you can get is one.
‫So 0.89 plus 0.11.
‫And then if we did the same for the next one, 0.49 plus 0.51, you kind of get the point there, right?
‫One one.
‫That's a maximum probability.
‫So what it's saying is that this sample.
‫Has a 0.89 probability of the label being zero.
‫And the next sample here, which gets the label one.
‫Has a 0.51.
‫So slightly only just slightly does that have a probability of being labeled one?
‫So that's why it's assigned one.
‫When we call predict, we force the model to give us back one label.
‫So this is where Predict Probe comes in handy, right?
‫Is we want to figure out the probability that our sample is given a certain label.
‫So this one here is basically a coin toss, right?
‫It's almost 5050.
‫But the model you could probably say is pretty confident on this sample, this one here being zero because
‫it's 89 versus 0.11, the same one for here.
‫Right.
‫So this is number three.
‫The third index is given zero.
‫We see this one here.
‫So it's pretty -- confident that this one is not heart disease as well.
‫So that's the difference between predict and predict.
‫Problem is that if we did have more than two classes here, so if we had like ten labels, if you could
‫predict probe on it, you'd get values, probability, value for each of those classes that we had.
‫But because we only have two, we're getting it back arrays of two samples here.
‫And so the threshold, because we have two samples is whichever one has over 2.5.
‫So this is why this one has 0.0 over 0.5 and it gets assigned a label of one, same with the next one.
‫And this one has over 0.5.
‫So it gets assigned a label of zero, which is the index of this array here.
‫And then finally for this one, it gets assigned a label of one because this one is over 0.5 with a
‫value of 0.82.
‫Where could you use predict prober?
‫Well, maybe in the in the future, right.
‫You're working on this kind of project.
‫You want to make sure that your model is very confident, say we're deploying this to production.
‫Right?
‫We're using this in a hospital and we don't want our model to give us samples that only have probability
‫estimate of 0.51.
‫We want to go, hey, model only give us a samples.
‫So this is where we could use predict prober only give us the samples that are maybe even higher than
‫0.89.
‫Maybe we only want when our model is extremely confident and then we'll use that prediction.
‫Or maybe it is helpful to know which samples are our models not sure about.
‫Then maybe we could look at that sample and go, hey, why is that sample?
‫Why is this row?
‫Why is the model unclear about that?
‫Is there something we could fix up?
‫So that's the sort of the value there between predict and predict prober predict.
‫We'll give you a single label for each sample, whereas predict proba returns the probabilities of a
‫classification label and remember the maximum value here is if you add these up is one.
‫So the closer to one, the more inverted commas.
‫Sure, your model is that the prediction it's made is a certain class.
‫All right.
‫So now we've seen the two way main ways of making predictions using a classification model.
‫I want you to have a thing.
‫How can we make predictions using a regression model to revisit?
‫If you would go back up and look at our regression model code.
‫How can we make a prediction using our regression model?
‫Say, if we wanted to predict on our Boston housing data, set the median house price given a row and
‫different characteristics about a town.
‫I'll challenge you to that.
‫Maybe you'll figure it out before the next video, but otherwise we'll have a look at it then.