Question: Question 2 [ 2 0 pts ] You are given the stroke classification dataset in 'stroke.csv ' . The continuous features are: age, avg _

Question 2[20 pts]
You are given the stroke classification dataset in 'stroke.csv'.
The continuous features are: age, avg_glucose_level, and bmi. The rest are
discrete features. The label stroke is binary {0,bar(1)}.
NOTE: for each of the following parts show the relevant code snippet and print results.
a) Do the following in the list order:
Read in the dataset. We will treat the entire dataset as training.
Take the discrete features and one-hot encode them.
Take the continue features and standard scale them.
Construct X_train by hstacking the two feature matrices above. Also, setup y_train.
Print the shapes to confirm you got this part correctly. The below is my
implementation's shapes.
(X_train, y_train) shape: ,
b) Code the function
def logreg_gradient_descent(X, y, learning_rate=0.01, max_iters=1000)
that implements logistic regression full-batch gradient descent. The function returns two
items: the fitted weight vector (w_hat) and list of iteration log losses (loglosses). Do
it as follows:
First set np.random.seed(11), then initialize w_hat as a sample from a normal
distribution: np.random.normal(loc=0.0, scale=1, size=X.shape[1])
Setup an empty list for loglosses
Loop for max_iters to do:
Compute prediction probabilities on X using current w_hat.
With predictions, you can compute current iteration log_loss(y, y_preds).
Append this iteration log loss to loglosses list.
Update w_hat using logistic regression gradient update.
After loop return w_hat, loglosses
Just show snippet for your function implementation.
Question 2 [ 2 0 pts ] You are given the stroke

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 Programming Questions!