All problems
PCA Mean Centering
Problem
Center each column of X by subtracting its column mean, producing data with zero mean per feature.
X is a list of rows; return a new matrix of the same shape. Empty input returns [].
Hint
Compute column means first, then subtract element-wise.
Test cases
case 1
in: [[[1,2],[3,4],[5,6]]]
expected: [[-2,-2],[0,0],[2,2]]
case 2
in: [[[0,0],[10,20],[20,40]]]
expected: [[-10,-20],[0,0],[10,20]]
case 3
in: [[[1,1],[1,1]]]
expected: [[0,0],[0,0]]
case 4
in: [[]]
expected: []
Starter codePython
def mean_center(X):
# Your code here
pass4 test cases · run your code against them in the editor