Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-023

Standardization of Feature Values

Problem

Standardize values to zero mean and unit variance using the population variance (divide by n): z_i = (x_i - mean) / std.

If the variance is 0, return a list of zeros. Empty input returns [].

Hint

The population standard deviation divides the squared deviations by n, not n-1.

Test cases

case 1
in: [[1,2,3]]
expected: [-1.224744871391589,0,1.224744871391589]
case 2
in: [[0,0,10,10]]
expected: [-1,-1,1,1]
case 3
in: [[5,5,5]]
expected: [0,0,0]
case 4
in: [[]]
expected: []
Starter codePython
def standardize(values):
    # Your code here
    pass

4 test cases · run your code against them in the editor