Discord-inspired abuse-detection experiment has correlated features that make an ordinary least-squares solution unstable. You need to compute the ridge-regression solution with the supplied regularization strength so the team has a stable baseline.
Solve the ridge-regression problem without an intercept: w^=(X⊤X+λI)−1X⊤y, computed with a linear solve rather than an explicit inverse.
Implement solve(X, y, lam).
Returns. Return the coefficient vector (one entry per column of X). lam must be non-negative.
Example 1
Input:
solve([[1, 0], [0, 1]], [1, 2], 1)
Output:
[0.5, 1.0]
Example 2
Input:
solve([[1.0, 1.0], [2.0, 2.0], [3.0, 3.0]], [1.0, 2.0, 3.0], 0.1)
Output:
[0.498221, 0.498221]
No results yet
Run your code to check it against the examples, or submit to run every test.