# Optional Lab: Classification and Optional Lab: Logistic Regression

Hi everyone,

I am facing troubles understanding the code written in some parts

can anyone help me ?

Please give details on which part of the assignment you are referring to, so that the mentors/community can try to help.

Hi @Kic

In Classification optional lab :
ax[0].scatter(x_train[pos], y_train[pos], marker=‘x’, s=80, c = ‘red’, label=“y=1”)
ax[0].scatter(x_train[neg], y_train[neg], marker=‘o’, s=100, label=“y=0”, facecolors=‘none’,
edgecolors=dlc[“dlblue”],lw=3)

ax[0].set_ylim(-0.08,1.1)
ax[0].set_ylabel(‘y’, fontsize=12)
ax[0].set_xlabel(‘x’, fontsize=12)
ax[0].set_title(‘one variable plot’)
ax[0].legend()

#plot 2, two variables
plot_data(X_train2, y_train2, ax[1])
ax[1].axis([0, 4, 0, 4])
ax[1].set_ylabel(‘x_1’, fontsize=12)
ax[1].set_xlabel(‘x_0’, fontsize=12)
ax[1].set_title(‘two variable plot’)
ax[1].legend()
plt.tight_layout()
plt.show()

What is ax[1], why it is not plt ?

ax is an object to do with plotting a graph. ax[0] is one object, ax[1] is another. Here the plotting is done by calling an utility function plot_data().
You can see the code for plot_data() by clicking
file->open->lab-ultis_common.py
This function is under the common plotting routines section.

After calling plot_data() in the optional notebook, the rest of the code is to specify the look and feel of the graph, as well as providing info about the graph, such as title, legend etc.

Here are a couple of links for further information: