KsDriftScenario
Statistics scenarios · Implementation: mlsysim/engine/scenario_definitions/statistics.py.
Construct this scenario with keyword inputs. The fields below show the types and defaults declared by this class.
A two-sample K-S drift test of n_reference training against n_current recent values of one feature.
Notes
Equation: critical statistic = coefficient * sqrt((n_reference + n_current) / (n_reference * n_current)).
Assumptions: The supplied coefficient matches the intended test level and the standard two-sample K-S assumptions; policy gate is distinct from significance.
Excludes: A p-value, repeated-testing correction, and proof that distribution drift reduces model quality.
References
Derivation: critical statistic = coefficient sqrt((n_reference + n_current) / (n_reference n_current)). The individual properties state units and intermediate accounting; this class introduces no fitted coefficient.
Examples
The named scenario supplies illustrative inputs; the output is calculated.
>>> from mlsysim import Scenarios
>>> case = Scenarios.LoudnessDriftKs1000
>>> round(float(case.scale), 3)
0.045Attributes
| Name | Description |
|---|---|
| alert_gate | |
| coefficient | |
| critical_value | Dimensionless K-S threshold from physics.statistics.calc_ks_critical_value. |
| flags | Whether the supplied observed K-S statistic exceeds the critical value; equality |
| gate_over_critical | Policy alert gate divided by the statistical critical value, a dimensionless |
| n_current | |
| n_reference | |
| observed_statistic | |
| scale | Two-sample size factor in the K-S threshold, excluding the confidence coefficient. |
| significance |
Methods
| Name | Description |
|---|---|
| flags_statistic | Whether a candidate dimensionless K-S statistic exceeds this scenario’s critical |
flags_statistic
engine.scenario_types.KsDriftScenario.flags_statistic(statistic)Whether a candidate dimensionless K-S statistic exceeds this scenario’s critical value.
Equation: return statistic > critical_value.
coefficient
Type: float.
Declared default: required.
n_reference
Type: int.
Declared default: required.
n_current
Type: int.
Declared default: required.
observed_statistic
Type: Optional[float].
Declared default: None.
significance
Type: Optional[float].
Declared default: None.
alert_gate
Type: Optional[float].
Declared default: None.
gate_over_critical
engine.scenario_types.KsDriftScenario.gate_over_critical
Policy alert gate divided by the statistical critical value, a dimensionless multiple.
Equation: return alert_gate / critical_value.
scale
engine.scenario_types.KsDriftScenario.scale
Two-sample size factor in the K-S threshold, excluding the confidence coefficient.
Equation: return critical_value / coefficient.
critical_value
engine.scenario_types.KsDriftScenario.critical_value
Dimensionless K-S threshold from physics.statistics.calc_ks_critical_value.
Equation: return calc_ks_critical_value(coefficient, n_reference, n_current).
flags
engine.scenario_types.KsDriftScenario.flags
Whether the supplied observed K-S statistic exceeds the critical value; equality does not flag.
Equation: return observed_statistic > critical_value.