Question: COMPLETE THE MATLAB CODE The sigmoid function is used in logistic regression to calculate probabilities of belonging to one of two classes. The function, in

COMPLETE THE MATLAB CODE

COMPLETE THE MATLAB CODE The sigmoid function is used in logistic regressionto calculate probabilities of belonging to one of two classes. The function,

The sigmoid function is used in logistic regression to calculate probabilities of belonging to one of two classes. The function, in its purest form 0(x) = -1 1 te- maps negative x to values less than 0.5 and positive x to values larger than 0.5. However, this form might not fit the data well. Suppose you wanted to predict if a student would pass an exam (1) or not (0) based on the number of hours spent studying x. In this case, the feature x cannot be negative, so everything would be predicted as 1 (pass). We can introduce trainable parameters a and b to give the sigmoid function more flexibility to fit the data: 0(x; a, b) = - 1+e-ax+b) The goal in logistic regression is to train the algorithm (with gradient descent) to find the a and b that best fit the data. The range of this function is still (0,1); the parameters only shift the function left/right and change its curvature. In this problem, you will try two combinations of a and b, and observe how they change the shape of the sigmoid function and the prediction it yields. Specifically, you will see how the prediction of test case x = 1.0 depends on a and b. You can submit your work as many times as you want. Try to get 100%. for ii = 1:2 %each of two cases if ii == 1 %first combination %you can change these parameters, but set them to their default values when submitting %defaults: a = 2.1; b = 0.5 a = 2.1; b = 0.5; else %second combination %defaults: a = 0.4; b = -2.6 a = 0.4; b =-2.6; end figure) %makes a new figure window x = linspace(-15, 15, 1000); %creates 1000 xvalues between -15 and 15 y = %YOUR CODE HERE. calculate the sigmoid of each x using a and b parameters x_test = 1.0; %we will assign this test data point to either class or class 1 y_test = %YOUR CODE HERE. calculate the sigmoid of the test case using parameters a and b. Similar to Line 13 threshold = %YOUR CODE HERE. What value of sigmoid function separates class from class 1? %---print some diagnostics, in this case, the class assignment fprintf(' When a = %.1f and b = %.1f,',a,b) if y_test

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!