Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 7 . A Use the cell below to define a function train _ logreg ( ) . The function should accept four parameters named

Part 7.A
Use the cell below to define a function train_logreg(). The function should accept four parameters named X, y, alpha, and n. Descriptions of the parameters are as follows:
X is expected to be a 2D feature array.
y is expected to be a 1D label array.
alpha is expected to be a learning rate.
steps is the number of iterations of gradient descent to perform during training.
The function should apply gradient descent to determine optimal parameters for a logistic regression model. An outline of the steps that the function should perform is provided below.
The function add_ones() should be used to create an "extended" feature matrix XE.
A coeficient array named betas should be created with all values initialized to zero. The following code can be used for this task: betas = np.zeros(XE.shape[1])

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

Critically discuss what is the point of audit?

Answered: 1 week ago