Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago