[HELP] Unable to understand the use of "[:,1]" in the solution

My Code:

``````testing_probs[origin]=models[origin].predict_proba(X_test)[:,1]
``````

Kindly explain the execution of the aforementioned line of code.
Kindly explain the above line and in above mentioned loc why we used the [:,1] at the end of this line?

`predict_proba()` returns an array containing probability values for each class you have.

Since you are using binary classification, you have two classes. The first column corresponds to the class `False` and the second one corresponds to the class `True`.

So, if you are trying to predict if a car was made in Europe or not, then the first column gives the probability that the car was not made in Europe and the second column gives the probability that the car was made in Europe.

Since we are outputting the model predictions we want the values from the 2nd column. That’s why the `[:, 1]`.

Hello,
Thanks for the quick response. So, this means by using [:,1] I am finding out the probability of True or 1 for the particular class in the loop? and if I use 0 then it will return the probability for the False or 0 for the class? is it so?

Yes, that’s correct. I recommend going through the documentation of the function as well to understand it a bit better.