Skip to content

Weighted anomaly scores - #34

Open
cgueck895 wants to merge 4 commits into
developfrom
weighted-anomaly-scores
Open

cgueck895 wants to merge 4 commits into
developfrom
weighted-anomaly-scores

Conversation

@cgueck895

@cgueck895 cgueck895 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Added

  • New WeightedRMSEScore anomaly score (weighted_rmse) that applies per-feature weights to
    standardized reconstruction errors before computing the RMSE, enabling feature-specific
    importance in anomaly detection.
  • New RMSEScore.standardize() and MahalanobisScore.standardize() helper methods, extracted
    from the respective transform() methods, to share the standardization logic.
  • New covariance_method parameter on MahalanobisScore ("auto" | "min_cov_det" |
    "shrinkage"), with support for full-dimensionality (non-PCA) Mahalanobis norm computation on
    mean-centred reconstruction errors.
  • New min_cov_det_ratio (default 2.0) and shrinkage_method ("oas" | "ledoit_wolf")
    parameters to control the automatic covariance-estimator selection.
  • New documentation page docs/anomaly_scores.rst explaining the available anomaly scores and
    when to use which, recommending RMSE as the default (linked from docs/index.rst).

Changed

  • MahalanobisScore now always standardizes reconstruction errors before applying PCA and
    the Minimum Covariance Determinant (MinCovDet) estimation (previously only when scale=True).
  • RMSEScore reconstruction errors are always standardized (behavior unchanged from before).
  • MahalanobisScore default clean path (pca=False) with covariance_method="auto" now uses
    MinCovDet only when it is stable (n/p >= min_cov_det_ratio and the covariance is full-rank and
    well-conditioned); otherwise it falls back to a shrinkage estimator (Ledoit-Wolf/OAS), keeping
    the score stable for low sample-to-feature ratios and collinear/high-dimensional features.

Deprecated

  • RMSEScore(scale=...) and MahalanobisScore(scale=...): the scale parameter no longer has
    any effect and is accepted only for backwards compatibility. Passing it now emits a
    DeprecationWarning. It will be removed in a future release; omit it (standardization is
    always applied).
  • MahalanobisScore(pca=True): the PCA-based path is deprecated and will be replaced by the clean
    full-dimensionality Mahalanobis norm implementation. Use pca=False (with covariance_method
    for covariance-estimator control) instead.

Removed

  • The anomaly_score.params.scale key from the advanced configuration example
    (docs/examples/advanced_config.yaml) for rmse (and scale from the mahalanobis example
    in the class docstrings).

@cgueck895
cgueck895 requested a review from roelofsc September 15, 2026 12:29
@cgueck895
cgueck895 force-pushed the weighted-anomaly-scores branch from 04fc675 to 90172c7 Compare September 15, 2026 12:46
@roelofsc

roelofsc commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Shouldn't the .standardize() method not be part of the AnomalyScore ABC? Since now all score classes use it.

chr39552 added 2 commits September 16, 2026 15:30
…precated pca-based mahalanobis_score. Also added documentation on anomaly scores
Loading a FaultDetector reconstructs each sub-model with no constructor
arguments, which previously raised a TypeError for the weighted_rmse score
because feature_weights was a required parameter. Default it to None and
add unit tests covering the FaultDetector save/load round-trip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants