---
id: wiki-2026-0508-root-mean-square-error
title: Root Mean Square Error
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [RMSE, Root Mean Squared Error, L2 loss surrogate]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [statistics, regression, loss-function, evaluation]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: python
  framework: scikit-learn / numpy
---

# Root Mean Square Error

## 매 한 줄
> **"매 RMSE는 squared residuals 의 sqrt mean — 매 outlier penalize 강하게"**. Gauss (1809) 의 least-squares 에서 도출, 매 modern ML 에서 regression default loss 의 backbone (MSE 의 사촌). 2026 LLM eval pipeline (chrF 외 numeric task) 부터 forecasting MAPE 비교까지 매 표준 metric.

## 매 핵심

### 매 정의
- `RMSE = sqrt(mean((y_true - y_pred)^2))`.
- 매 unit 이 target 의 unit 과 동일 — 매 interpretability 우위 (vs raw MSE).
- L2 norm 기반 — 매 large error 를 quadratic 으로 penalize.

### 매 vs MAE
- **RMSE > MAE** 항상 (Jensen) — 매 equality iff 모든 residual 동일.
- `RMSE/MAE` ratio → 매 outlier 의 indicator (1 ≈ uniform, >1.5 → heavy tail).
- MAE 는 robust, RMSE 는 sensitive — 매 차이를 modelling decision 으로 활용.

### 매 응용
1. Regression model selection (sklearn `mean_squared_error(squared=False)`).
2. Time-series forecasting (Prophet, NeuralProphet, TiDE).
3. NeRF / Gaussian Splatting reconstruction quality (PSNR = 20·log10(MAX/RMSE)).
4. RL value-function fitting (TD-error RMS).

## 💻 패턴

### Numpy 직접
```python
import numpy as np

def rmse(y_true, y_pred):
    y_true = np.asarray(y_true, dtype=np.float64)
    y_pred = np.asarray(y_pred, dtype=np.float64)
    return np.sqrt(np.mean((y_true - y_pred) ** 2))
```

### sklearn 1.6+ (squared=False deprecated)
```python
from sklearn.metrics import root_mean_squared_error  # sklearn ≥1.4

score = root_mean_squared_error(y_true, y_pred)
```

### Streaming / online (Welford-style)
```python
class StreamingRMSE:
    __slots__ = ("n", "sse")
    def __init__(self):
        self.n, self.sse = 0, 0.0
    def update(self, y, p):
        self.n += 1
        self.sse += (y - p) ** 2
    @property
    def value(self):
        return (self.sse / self.n) ** 0.5 if self.n else float("nan")
```

### PyTorch loss (MSE → RMSE)
```python
import torch.nn.functional as F

def rmse_loss(pred, target, eps=1e-8):
    return torch.sqrt(F.mse_loss(pred, target) + eps)  # eps for grad stability at 0
```

### Weighted RMSE (sample importance)
```python
def weighted_rmse(y, p, w):
    w = np.asarray(w, dtype=np.float64)
    return np.sqrt(np.sum(w * (y - p) ** 2) / np.sum(w))
```

### Per-segment RMSE (cohort analysis)
```python
import pandas as pd

def cohort_rmse(df, segment_col, y_col, p_col):
    return df.groupby(segment_col).apply(
        lambda g: rmse(g[y_col], g[p_col])
    ).rename("rmse")
```

### NRMSE (normalized) — 매 cross-domain comparison
```python
def nrmse(y, p, mode="range"):
    base = (y.max() - y.min()) if mode == "range" else y.mean()
    return rmse(y, p) / base
```

## 매 결정 기준

| 상황 | Approach |
|---|---|
| Outlier sensitive 원함 | RMSE |
| Robust 원함 (heavy-tail) | MAE / Huber |
| Cross-dataset 비교 | NRMSE / MAPE |
| Imbalanced cost | Weighted RMSE |
| Probabilistic forecast | CRPS (RMSE 의 distribution generalization) |

**기본값**: regression model 의 first-pass metric 은 RMSE + MAE 동시 report.

## 🔗 Graph
- 부모: [[Statistics]] · [[Regression-Analysis-Foundations]]
- 변형: [[Standard-Deviation-and-Variance]] · [[Least-Squares-Methods]]
- 응용: [[Kalman-Filter-and-State-Tracking]] · [[VPS_NeRF]]
- Adjacent: [[Information-Entropy]] · [[Probability Theory|Probability-Theory-Foundations]]

## 🤖 LLM 활용
**언제**: numeric regression eval, calibration check, residual analysis 의 first-line metric.
**언제 X**: classification (use accuracy/F1/AUC), ranking (NDCG/MRR), generation (BLEU/chrF/BERTScore).

## ❌ 안티패턴
- **단일 RMSE 만 report**: 매 distribution shape 을 hide — MAE / R² / residual plot 동반.
- **Cross-scale RMSE 비교**: target unit 다른 dataset 간 raw RMSE 비교는 의미 X — normalize.
- **RMSE 로 outlier 검출**: cause / effect 혼동 — RMSE 는 outlier 영향을 받지, 검출하는 도구 X.
- **0 부근 sqrt grad NaN**: `sqrt(MSE + eps)` 또는 MSE 로 train, RMSE 로 report.

## 🧪 검증 / 중복
- Verified (Hyndman & Koehler 2006, "Another look at measures of forecast accuracy"; sklearn docs 1.6).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — RMSE definition, sklearn 1.6 API, streaming/weighted/NRMSE patterns, decision matrix |
