1

Experiment: effect of L1 regularization strength

Unsolved
Fundamentals

Difficulty: 5 | Problem written by peter.washington
Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

Return the mean and standard deviation (as a tuple) of the testing accuracy score (via the score scikit-learn method) on the handwrittetn digits dataset when training a logistic regression classifier with L1 regulariization with different regularization strengths. You will be provided a list of regularization strengths to use in the experiments as input.

Use the scikitlearn library. You can import the handwritten digits dataset and the logistic regression classifier with the following code:

from sklearn.datasets import load_digits
from sklearn.linear_model import LogisticRegression

X, y = load_digits(return_X_y=True)

Use the 'liblinear' solver for the Logistic Regression classifier. See LogisticRegression documentation here: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html. Use a random state of 5.

This code may take a few seconds or minutes to run because the model will be trained across several conditions. 

Sample Input:
<class 'list'>
regularization_strengths: [0.1, 0.5, 0.9]

Expected Output:
<class 'tuple'>
(0.9894268224819144, 0.005675035630042081)

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Dolore sunt obcaecati ut id quod vel et aperiam porro quo, neque dolore consequatur dolor culpa officiis, doloribus id nam esse iusto rem corporis optio in est porro maxime, dolorem ex repellendus mollitia repellat voluptatum, velit in quisquam eveniet quia natus enim. Id dolor eos. Numquam aperiam ducimus perspiciatis illo aliquam corporis doloremque iure nobis accusamus.

Incidunt rerum commodi fugiat repudiandae necessitatibus libero placeat perferendis, aliquam corporis officiis facere aspernatur quod, vero eos dolore inventore optio reiciendis officiis ad assumenda earum, quod cumque at impedit cum explicabo praesentium, placeat iure nobis? Eum architecto animi hic atque distinctio dolorem est error eius nemo, tenetur sequi voluptatem aspernatur quia quaerat sed fugiat? Sunt sapiente incidunt provident, dolore architecto dignissimos provident eligendi cumque veritatis error. Officiis quae ad ipsum, nam modi odio officiis culpa nisi dolor voluptates vitae qui voluptate.

Excepturi beatae est debitis quasi? Ab eum laboriosam nam magnam similique iste quam commodi ad sequi quo, mollitia maxime iusto quae cupiditate quia velit aliquid quod officia ad sequi, commodi pariatur earum repellat sed odit nesciunt cumque.

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)