# Week 3 Assignment on Logistic Regression Questions

I have the following questions from the assignment on logistic regression:

1. Section 2.6 Learning parameters using gradient descent uses theta. What is theta here?
2. Could someone explain what X[positive, 0], X[positive, 1] does in the plot_data function in utils.py for the assignment on logistic regression? I read here:
Pyplot tutorial — Matplotlib 3.7.2 documentation that corresponding values of arrays are matched eg. If we have plt.plot([1,2,3,4],[1,4,9,16], 'ro’), the points to be plotted are: (1,1), (2,4), (3,9), (4,16) but I don’t quite understand how it works in our function below
def plot_data(X, y, pos_label="y=1", neg_label="y=0"):
positive = y == 1
negative = y == 0
# Plot examples
plt.plot(X[positive, 0], X[positive, 1], 'k+', label=pos_label)
plt.plot(X[negative, 0], X[negative, 1], 'yo', label=neg_label)


Hello @mvrbiguv,

1. 'theta' are used in the DocString of the function gradient_descent. theta, or its symbol form \theta, is commonly used to represent all of the trainable parameters (weights and biases). It is also a common notation in a machine learning text book. It’s like a synonym for weights and biases.

2. I will let you figure that out yourself, but I can give you four points to begin with:

1. You need to understand a topic called “indexing”, because X[y==0, 0] is a Boolean array indexing. Indexing is a must-know if you want to be proficient in numpy.
2. Note that in the MLS convention, X’s rows (0th-dimension) represent samples, and X’s columns (1st-dimension) represent features.
3. Start experimentation from a pair of toy X and y created by yourself. Make them managable, like a 4 x 2 X and a y of length 4. That’s 4 samples and 2 features, and 4 labels. Repeat X[y==0, 0] and see what it gives you. Repeat the experiments with a few other simple toy X and y and you should be able to find out what’s happening there.
4. Return to the actual X, y, and plot_data. Repeat the experiment on them, and see if things make sense with the resulting plot.

Good luck!
Raymond