Leak-Free History Feature Builder (ml/history_features.py)

sage · src/sage/ml/history_features.py · python · MIT
ai, lang:python, tag:feature-engineering, tag:time-series, tag:failure-prediction

Builds expanding-window, Laplace-smoothed historical failure-rate features (per command, family, kind) for ML failure prediction without leaking future outcomes.

# Source: https://github.com/PsYcGoD/sage | License: MIT | Copyright 2025 PsYcGoD (SAGE Project)
# Provided via justclaw.it.com; keep this notice with the code.
"""Leak-free historical features for failure prediction.

The strongest failure signal is history: did this exact command, this
command family, or this command kind fail before? These features are built
with an expanding window — each sample only ever sees runs that happened
BEFORE it — so temporal validation stays honest and training cannot leak
future outcomes into the past.

Failure rates are Laplace-smoothed toward the running global rate so a
single old failure does not pin a command at 100% risk forever.
"""

from __future__ import annotations

from ..classify import classify_command, command_fingerprint

HISTORY_FEATURE_NAME

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key