3. Recall that the logistic regression hypothesis is defined as: holx) = g(@"x), where function g is the sigmoid function. The sigmoid function is defined as: g(2) = Implement the sigmiod function so it can be called by the rest of your program. When done, try testing a few values by calling sigmoid(x) in the code section below. For large positive values of x, the sigmoid should be close to 1, while for large negative values, the sigmoid should be close to 0. Evaluating sigmoid(0) should give you exactly 0.5. Your code should also work with vectors and matrices. For a matrix, your function should perform the sigmoid function on every element. * Provide different input values and check your implementation sigmoid(e) function g- sigmoid(z) B - zeros(size(z)); [m,n]=size(z); * Instructions: Compute the sigmoid of each value of z (z can be a matrix, vector or scalar). for i-1:m for j-1:n g(1,1)-1/(1+exp(-z(1,j))); end end end

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

write code in Phython 

3. Recall that the logistic regression hypothesis is defined as:
holx) = g (@"x),
where function g is the sigmoid function. The sigmoid function is defined as:
g(2):
1+e
Implement the sigmiod function so it can be called by the rest of your program. When done,
try testing a few values by calling sigmoid(x) in the code section below. For large positive
values of x, the sigmoid should be close to 1, while for large negative values, the sigmoid
should be close to 0. Evaluating sigmoid(0) should give you exactly 0.5. Your code should also
work with vectors and matrices. For a matrix, your function should perform the sigmoid
function on every element.
% Provide different input values and check your implementation
sigmoid(0)
function g = sigmoid(z)
g = zeros (size(z));
[m,n]=size(z);
% Instructions: Compute the sigmoid of each value of z (z can be a matrix,
vector or scalar).
for i-1:m
for j-1:n
g(i,j)=1/(1+exp(-z(i,j)));
end
end
end
Transcribed Image Text:3. Recall that the logistic regression hypothesis is defined as: holx) = g (@"x), where function g is the sigmoid function. The sigmoid function is defined as: g(2): 1+e Implement the sigmiod function so it can be called by the rest of your program. When done, try testing a few values by calling sigmoid(x) in the code section below. For large positive values of x, the sigmoid should be close to 1, while for large negative values, the sigmoid should be close to 0. Evaluating sigmoid(0) should give you exactly 0.5. Your code should also work with vectors and matrices. For a matrix, your function should perform the sigmoid function on every element. % Provide different input values and check your implementation sigmoid(0) function g = sigmoid(z) g = zeros (size(z)); [m,n]=size(z); % Instructions: Compute the sigmoid of each value of z (z can be a matrix, vector or scalar). for i-1:m for j-1:n g(i,j)=1/(1+exp(-z(i,j))); end end end
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education