milia.anomaly.models.controllimit#
Shewhart control limit: the largest standardised deviation of any reading from its training mean.
Classes
|
Three-sigma control limit on every reading of a profile (Shewhart; Montgomery, 2019). |
|
Validated hyperparameters of the control-limit detector. |
- class milia.anomaly.models.controllimit.ControlLimit(limit=None, contamination=0.1)#
Bases:
BaseDetectorThree-sigma control limit on every reading of a profile (Shewhart; Montgomery, 2019).
Each column (for a daily profile, each half-hour) is standardised by its training mean and standard deviation, and a row’s score is its largest absolute standardised deviation. The control-chart rule flags a row when any reading lies more than
limitstandard deviations from its mean: withlimit=3the threshold afterfit()is that rule. Without a limit the threshold is the trainingcontaminationquantile, as for every detector, andcalibrate()replaces either with a conformal threshold. It is the simplest baseline against which the complexity of other detectors is assessed.- Parameters:
Examples
>>> rng = np.random.default_rng(0) >>> train = rng.normal(size=(500, 4)) >>> ControlLimit(limit=3.0).fit(train).flag(np.array([[0.0, 0.0, 0.0, 0.0], [0.0, 5.0, 0.0, 0.0]])).tolist() [False, True]
- fit(X, y=None)#
Estimate the mean and spread of every column, and set the threshold to
limitif given.- Parameters:
- Return type:
- Returns:
The fitted detector.
- Raises:
ValueError – If
limitis not positive.
- class milia.anomaly.models.controllimit.ControlLimitConfig(*, name='controllimit', kind='detector', space=SearchSpace(limit=(2.0, 4.0)), limit=None, contamination=0.1)#
Bases:
BaseModelConfigValidated hyperparameters of the control-limit detector.
Fields mirror
ControlLimit’s constructor;spaceis the default Optuna search space. Build the detector withmake("detector", "controllimit", ...)orControlLimit(**config.params()).Examples
>>> ControlLimitConfig().name 'controllimit'