Compute the sample covariance matrix of a data matrix X with n rows (samples) and d columns (features), dividing by n−1.
Implement solve(X).
Returns. Return a symmetric d×d float NumPy array. At least two rows are needed; a single row has no sample covariance (the result is nan).
Example 1
Input:
solve([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
Output:
[[4.0, 4.0], [4.0, 4.0]]
Example 2
Input:
solve([[1.0, 0.0], [2.0, 0.0], [3.0, 0.0]])
Output:
[[1.0, 0.0], [0.0, 0.0]]
No results yet
Run your code to check it against the examples, or submit to run every test.