Train Versus Test Accuracy Gap

~6 mincode completion

Implement accuracy_gap(train_acc, test_acc) returning the array [gap, flag], where flag is 1.0 for likely memorizing and 0.0 otherwise.

Where this shows up

~6 min

7 employers weight this skill

2 health and bio companies, 2 quant funds, 2 enterprise vendors, 1 AI product company. Top match scores 50.

Python
import numpy as np


def accuracy_gap(train_acc, test_acc):
    """
    How far the training score sits above the test score.

    Args:
        train_acc: accuracy on the training set, in percent (0 to 100)
        test_acc:  accuracy on the test set, in percent (0 to 100)

    Returns:
        array [gap, flag]: gap in percentage points, flag 1.0 if gap > 10 else 0.0
    """
    # YOUR CODE HERE
    pass

Run your code to see results

⌘↵ runs against the visible tests

Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.