|
|
||||
|
Problem 1: Logistic Regression In this problem, we’ll build a logistic regression classifier and train it on separable and non-separable data. Since it will be specialized to binary classification, we’ve named the class logisticClassify2 . We start by creating two binary classification datasets, one separable and the other not: 1 2 3 4 5 6 7
For this problem, we focus on the properties of the logistic regression learning algorithm, rather than classification performance. Thus we will not create a separate validation dataset, and simply use all available data for training. 1. For each of the two datasets, create a separate scatter plot in which the training data from the two classes is plotted in different colors. Which of the two datasets is linearly separable? (5 points) 2. Write (fill in) the function plotBoundary in logisticClassify2.py to compute the points on the decision boundary. In particular, you only need to make sure x2b is set correctly using self.theta . This will plot the data & boundary quickly, which is useful for visualizing the model during training. To demonstrate your function, plot the decision boundary corresponding to the classifier sign(2+6×1−1×2 ) data set, but a poor classifier on the other. You can create a “blank” learner and set the weights as follows:
1 2 3 4 5 6 7 Include the lines of code you added to the plotBoundary function, and the two generated plots. (10 points) |
||||
|
|
Plotting hints: The code generates plots as the algorithm runs, so you can see its behavior over time; this is done by repeatedly clearing the plot axes via . In Jupyter, you also need to clear the Jupyter display using . Debugging hints: Debugging machine learning algorithms can be quite challenging, since the results of the algorithm are highly data-dependent, and often somewhat randomized (from the initialization, as well as the order points are visited by stochastic gradient descent). We suggest starting with a small step size and verifying both that the learner’s prediction evolves slowly in the correct direction, and that the objective function J decreases. If that works, explore the convergence of the algorithm with larger step sizes; if not, check the computation of the gradient and the optimization loop. It is often useful to manually step through the code, for example by pausing after each parameter update using input() . Of course, you may also use a more sophisticated debugger. where y(j) is 0 or 1. iii IPython.display.clear_output() pyplot.cla() |
|
Homework 3 UC Irvine 2/ 3 |
|
CS 178: Machine Learning & Data Mining Fall 2020 |
|
(a) (b) (c) (d) separate their all possible binary colorings. No three data points are on a line. Problem 2: Shattering and VC Dimension (15+5 points) Consider the data points in Figure 1 which have two real-valued features x1, x2. We are also giving a few learners below. For the learners below, T[z] is the sign threshold function, T[z] = +1 for z ≥ 0 and T[z] = −1 for z < 0. The learner parameters a, b, c, . . . are real-valued scalars, and each data point has two real-valued features x1, x2. Which of the four datasets can be shattered by each learner? Give a brief explanation/justification and use your results to guess the VC dimension of the classifier (you do not have to give a formal proof, just your reasoning). 1. T(a+bx1)(5points) 2. T((a∗b)x1+(c/a)x2)(5points) 3. T((x1−a)2+(x2−b)2+c)(5points) 4. ExtraCredit: T(a+bx1+cx2)×T(d+bx1+cx2)(5points) Hint: The two equations are two parallel lines. Problem 3: Statement of Collaboration (5 points) It is mandatory to include a Statement of Collaboration in each submission, that follows the guidelines below. Include the names of everyone involved in the discussions (especially in-person ones), and what was discussed. All students are required to follow the academic honesty guidelines posted on the course website. For programming assignments in particular, I encourage students to organize (perhaps using Piazza) to discuss the task descriptions, requirements, possible bugs in the support code, and the relevant technical content before they start working on it. However, you should not discuss the specific solutions, and as a guiding principle, you are not allowed to take anything written or drawn away from these discussions (no photographs of the blackboard, written notes, referring to Piazza, etc.). Especially after you have started working on the assignment, try to restrict the discussion to Piazza as much as possible, so that there is no doubt as to the extent of your collaboration. Problem 4: Halloween (5 points) What did you do for Halloween? |
|
Homework 3 UC Irvine 3/ 3 |



