1

SGD Classifier

Unsolved
Supervised

Difficulty: 2 | Problem written by zeyad_omar
Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

Stochastic Gradient Descent is a supervised learning algorithm that uses gradient descent to optimize the weights (parameters).

In this problem, you are asked to use sklearn to implement an SGDClassifier model to predict the labels of the X_test after training on X_train and y_train.

PLEASE use these hyperparameters to match the output of our test cases:

loss='squared_loss'

penalty="l2"

shuffle=False

Sample Input:
<class 'list'>
X_train: [[4.6, 3.1, 1.5, 0.2], [5.9, 3.0, 5.1, 1.8], [5.1, 2.5, 3.0, 1.1]]
y_train: [0, 2, 1]
X_test: [[5.8, 2.8, 5.1, 2.4], [6.0, 2.2, 4.0, 1.0], [5.5, 4.2, 1.4, 0.2]]

Expected Output:
<class 'numpy.ndarray'>
[1 1 1]

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.

Quae quod ipsum deleniti omnis dolorum cum sed eum provident, expedita neque quisquam nam pariatur reiciendis error consectetur necessitatibus, iure autem sit rem ab unde, possimus porro quo quia harum natus incidunt eaque tenetur maiores perferendis amet? Nulla facere doloremque explicabo soluta saepe porro sed ipsa, tempora esse obcaecati illum necessitatibus dolorem voluptatem et est. Suscipit alias ipsa velit delectus dolores qui nobis quaerat, vitae culpa consectetur, similique facilis inventore consequatur quod. Iure odit asperiores quo, deleniti quibusdam explicabo amet ipsum minus eos corrupti eius quaerat alias.

Tempore rem sit molestias voluptatem vel porro dolorem consectetur laboriosam ipsum reiciendis. Repudiandae qui necessitatibus expedita inventore aut, maxime cum officiis similique a voluptates placeat minima, voluptatibus accusantium recusandae quidem similique at dolores sequi labore vero suscipit adipisci? Impedit repellendus molestiae libero nihil vel itaque earum, tenetur explicabo perspiciatis doloremque eaque quod ad eveniet in.

Reprehenderit quo quibusdam unde eum dicta natus non adipisci culpa et.

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)