Root Mean Square Error (RMSE)
Statistical Inference DS practice problem on Onlearn.
Difficulty: easy.
Topics: Understanding Calculate Root Mean Square Error (RMSE), Root Mean Square Error, Euclidean Distance, Residual Analysis, Array Shape Invariance, Type Checking, Probability & Statistics, Linear Algebra, Numerical Analysis, Machine Learning Evaluation, Data Validation, Statistical Inference, Vector Norms, Error Metrics, Input Sanitization, Floating Point Arithmetic.
Task: Compute Root Mean Square Error (RMSE) In this task, you are required to implement a function rmse(y true, y pred) that calculates the Root Mean Square Error (RMSE) between the actual values and the predicted values. RMSE is a commonly used metric for evaluating the accuracy of regression models, providing insight into the standard deviation of residuals. Your Task: Implement the function rmse(y true, y pred) to: 1. Calculate the RMSE between the arrays y true and y pred. 2. Return the RMSE value rounded to three decimal places. 3. Ensure the function handles edge cases such as: Mismatched array shapes. Empty arrays. Invalid input types. The RMSE is defined as: $$ \text{RMSE} = \sqrt{\frac{1}{n} \sum {i=1}^{n} (y {\text{true}, i} y {\text{pred}, i})^2} $$ Where: $ n $ is the number of observations. $ y {\text{true}, i} $ and $ y {\text{pred}, i} $ are the actual and predicted values for the $ i $ th observation.