DataLane

2. Mean squared error

mediumProNot started~8 minPythonImplement mse()

Asked in screens shaped like: Google, OpenAI

Implement mse(y_true, y_pred): the mean of squared residuals, rounded to 4 decimal places.

Examples

  • Example 1

    Input: { "y_true": [1, 2, 3], "y_pred": [1, 2, 5] }
    Output: 1.3333

Constraints

  • Both arrays have the same length
  • 1 <= n <= 10**5, where n is the length of the input
  • Input is non-empty

Python editor

Loading Python engine…

Ctrl/Cmd + Enter submits

Run your code to see stdout.

Pro problem

Medium problems unlock with Pro

Easy pads stay free. Medium and hard SQL and Python problems — editor, tests, hints, and solutions — open after you upgrade to Pro or coaching.

See plansPractice free easy problems
↑↓ navigate openesc close