2025 USA-NA-AIO Round 1, Problem 3, Part 18

Part 18 (5 points, coding task)

Do the following tasks in this problem.

  1. Define two models:

    • model_GD = My_Log_Reg(solver='GD', lr=.01, num_iter=200)

    • model_Newton = My_Log_Reg(solver='Newton', lr=.1, num_iter=200)

  2. For each model,

    • Use the training dataset to train it.

    • Print the trained coefficients coef_.

    • Use the test dataset to compute the accuracy score. Print it.

### WRITE YOUR SOLUTION HERE ###
model_GD = My_Log_Reg(solver='GD', lr=.001, num_iter=200)
model_GD.fit(X_train_scaled, y_train)
print(model_GD.coef_)
print(model_GD.score(X_test_scaled, y_test))


model_Newton = My_Log_Reg(solver='Newton', lr=.1, num_iter=200)
model_Newton.fit(X_train_scaled, y_train)
print(model_Newton.coef_)
print(model_Newton.score(X_test_scaled, y_test))

""" END OF THIS PART """