Weighted RMSE
Difficulty: Medium · Concept: Linear Regression — The Cost Function
A harder variant of Mean Squared Error From Scratch: real training data is often not equally trustworthy — some examples might be known to be noisier, less representative, or more expensive to get wrong, and a per-example weight lets the loss reflect that directly. This also switches from MSE to RMSE (take the square root at the end) — same information, but back in the original units of the target, which is what makes an error number actually interpretable ("off by 2 degrees," not "off by 4 degrees-squared").
The genuine edge case: if every weight is 0 (or the weights list is otherwise degenerate), the denominator is 0 and the result is undefined — a real implementation needs to raise, not silently produce a ZeroDivisionError or a nan.
Your task: implement weighted_rmse(y_true, y_pred, weights). Raise ValueError if the three lists aren't the same length, or if the weights sum to 0.