Logical regression


why we are using meshgrid here and why there is the need of modifying X to X_new?

Hi,

  1. np.meshgrid will return the matrices from vectors.

Here you can see linspace() will create two vectors and to make it a matrices for further use we need to convert to matrix.

  1. Here we are not modifying the X to X_new.
    Here we are translating the flattened object of X0 and X1 along the second axis and storing it in a X_new variable.

To know more kindly refer below

https://numpy.org/doc/stable/reference/generated/numpy.c_.html
https://numpy.org/doc/stable/reference/generated/numpy.meshgrid.html

All the best!

why we are not directly predicting the X ?

Hi.
Here X0, X1 and X_new is basically used for plotting the contour graph along with zz as an example.

I cannot see any relations b/t the X_new and X used for prediction in the screenshots you shared.
“X” may have been used in later code for predictions.

Kindly send the compete code to look more into it.

All the best!

y_proba=log_reg.predict(X_new) is used ?
you can see in line 10.
What is the meaning of contour graph

Hi,
Yes that is fine y_proba=log_reg.predict(X_new) is using the X_new variable which you have created by meshgrid, but no where you are using X variable which consists of Iris data right?

You can refer below.
https://matplotlib.org/3.1.1/gallery/images_contours_and_fields/contour_demo.html