diff --git a/src/mcm_toolkit/models/metrics.py b/src/mcm_toolkit/models/metrics.py index 17159f2..334a26a 100644 --- a/src/mcm_toolkit/models/metrics.py +++ b/src/mcm_toolkit/models/metrics.py @@ -24,13 +24,13 @@ __all__ = [ def rmse(y_true: Any, y_pred: Any) -> float: """均方根误差。与 y 同量纲,最常用。""" - # TODO(L0) + # TODO(L1) raise NotImplementedError def mae(y_true: Any, y_pred: Any) -> float: """平均绝对误差。对离群值比 RMSE 稳健。""" - # TODO(L0) + # TODO(L1) raise NotImplementedError @@ -48,7 +48,7 @@ def smape(y_true: Any, y_pred: Any) -> float: def r2_score(y_true: Any, y_pred: Any) -> float: """决定系数 R²。注意:加变量一定会升高,跨模型比较要看 adjusted_r2。""" - # TODO(L0) + # TODO(L1) raise NotImplementedError diff --git a/src/mcm_toolkit/solve/simulate.py b/src/mcm_toolkit/solve/simulate.py index 810b76d..9aa6727 100644 --- a/src/mcm_toolkit/solve/simulate.py +++ b/src/mcm_toolkit/solve/simulate.py @@ -772,7 +772,6 @@ def mm1_metrics(arrival_rate: float, service_rate: float) -> Any: W = 1.0 / (service_rate - arrival_rate) # 平均逗留时间 Wq = W - 1.0 / service_rate # 平均等待时间 - # 4. 封装返回 metrics = { "rho": float(rho), "L": float(L), diff --git a/tests/test_models.py b/tests/test_models.py index 56acd5f..2bd5814 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -5,9 +5,10 @@ from __future__ import annotations import numpy as np import pytest -pytestmark = pytest.mark.skip(reason="未实现:见 docs/03-roadmap.md L1") +_NOT_IMPLEMENTED = "未实现:见 docs/03-roadmap.md L1" +@pytest.mark.skip(reason=_NOT_IMPLEMENTED) def test_fit_linear_recovers_known_coefficients(linear_data): """真值 y = 2x + 1,拟合系数应在 1% 内。""" from mcm_toolkit.models import fit_linear @@ -18,6 +19,7 @@ def test_fit_linear_recovers_known_coefficients(linear_data): assert np.isclose(r.params["intercept"], 1.0, atol=0.05) +@pytest.mark.skip(reason=_NOT_IMPLEMENTED) def test_fit_polynomial_matches_numpy(linear_data): from mcm_toolkit.models import fit_polynomial @@ -26,6 +28,7 @@ def test_fit_polynomial_matches_numpy(linear_data): assert np.allclose(r.params["coef"], np.polyfit(x, y, 2), rtol=1e-6) +@pytest.mark.skip(reason=_NOT_IMPLEMENTED) def test_metrics_known_values(): from mcm_toolkit.models import mae, r2_score, rmse @@ -36,6 +39,7 @@ def test_metrics_known_values(): assert r2_score(y_true, y_pred) < 1.0 +@pytest.mark.skip(reason=_NOT_IMPLEMENTED) def test_r2_is_one_for_perfect_fit(): from mcm_toolkit.models import r2_score @@ -43,6 +47,7 @@ def test_r2_is_one_for_perfect_fit(): assert np.isclose(r2_score(y, y), 1.0) +@pytest.mark.skip(reason=_NOT_IMPLEMENTED) def test_compare_models_returns_table_sorted_by_first_metric(linear_data): from mcm_toolkit.models import compare_models, fit_linear, fit_polynomial