1

When Do We Stop Training?

Unsolved
Neural Networks

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

Amazon
Apple
Facebook
Google
Netflix

In ML, the model may overfit, or memorize the training data. One of  the solutions to this problem is early stopping regularization where there is a point in the learning process at which the overfitting problem appears.

How do we know that overfitting is going to appear ?

The answer is by testing the model on unseen validation data. If the validation accuracy is increasing then no overfitting is occuring but if starts to decrease, then overfitting has occured.

In this problem, you are given a 1D vector that contains the validation accuracy of the model, and you are asked to return the index at which the validation accuracy begin to decrease (as it would be an indication that we are overfitting).

NOTE: It is acceptable to have some accuracy fluctuations, so you are given a threshold value, below which we do not consider overfitting to have happened.

Sample Input:
<class 'list'>
accuracy: [50, 51.2, 55, 57.9, 70, 71, 40]
threshold: 5

Expected Output:
<class 'int'>
5

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.

Impedit assumenda iure tenetur nemo itaque quidem perferendis modi qui, magni beatae sit voluptatibus cumque eos alias molestiae harum ut, exercitationem dolorem ducimus nihil repudiandae aut asperiores rerum libero. Praesentium officia officiis unde fuga sequi suscipit rem provident ab repellat recusandae, sapiente provident quis quasi sint earum magni iure, alias est provident veritatis id iste vero saepe. Eius earum ex, iste illum commodi et, eligendi ea vitae incidunt excepturi odit tempore.

Aliquid quo consequuntur nisi, aliquam est quo rerum dicta numquam deleniti, quibusdam sed ducimus perferendis qui quasi fugiat nesciunt. Sunt temporibus porro veritatis omnis dolor rem eum, possimus illo eveniet ea natus fugiat error inventore aperiam. Quas ab delectus iure, nam error molestias delectus ut quaerat laborum? Obcaecati repudiandae aut odio nisi, minima unde repudiandae maiores quos delectus error nam, vel dolorum recusandae, velit deserunt non, deserunt eaque assumenda amet corrupti neque cupiditate laboriosam libero architecto placeat.

Dicta beatae voluptatum suscipit dolorem, ipsa eos molestias nisi temporibus pariatur eum optio odit blanditiis, aliquam eveniet iusto ea cum porro voluptatum velit impedit reiciendis? Ullam repudiandae commodi facilis, autem libero provident consequatur, ut officiis necessitatibus corporis itaque error ea repellendus fugiat vel nobis, tempore nobis incidunt recusandae placeat culpa, ex error sint veniam. Ad pariatur eos vero est dicta.

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)