CRED-inspired risk analytics pipeline assigns different importance to observations based on their reliability. You need to compute the weighted covariance so the downstream model captures the relationship between features using those observation weights.
Normalise the weights to sum to 1 (pi=wi/∑w), compute the weighted mean μ=∑ipixi and return Σ=∑ipi(xi−μ)(xi−μ)⊤. No small-sample bias correction is applied.
Implement solve(X, w).
Returns. Return a symmetric d×d float NumPy matrix. The weights must be non-negative and not all zero.
Example 1
Input:
solve([[1, 2], [3, 4], [5, 1]], [1, 2, 1])
Output:
[[2.0, -0.5], [-0.5, 1.6875]]
Example 2
Input:
solve([[1.0, 0.0], [3.0, 2.0]], [1.0, 1.0])
Output:
[[1.0, 1.0], [1.0, 1.0]]
No results yet
Run your code to check it against the examples, or submit to run every test.