milia.anomaly.models.reconstruction#
Reconstruction error from the leading principal components (the Q statistic of multivariate process control).
Classes
|
Detector scoring a row by the squared error of its reconstruction from the leading principal components. |
|
Validated hyperparameters of the reconstruction detector. |
- class milia.anomaly.models.reconstruction.Reconstruction(components=5, random_state=0, contamination=0.1)#
Bases:
BaseDetectorDetector scoring a row by the squared error of its reconstruction from the leading principal components.
Normal rows lie close to the subspace their leading components span; a row whose shape the components cannot express leaves a large residual, the Q (squared prediction error) statistic of multivariate process control.
- Parameters:
Examples
>>> rng = np.random.default_rng(0) >>> base = rng.normal(size=(200, 2)) @ rng.normal(size=(2, 6)) >>> model = Reconstruction(components=2).fit(base) >>> odd = rng.normal(size=(1, 6)) * 5 >>> bool(model.score_samples(odd)[0] < model.score_samples(base[:1])[0]) True
- class milia.anomaly.models.reconstruction.ReconstructionConfig(*, name='reconstruction', kind='detector', space=SearchSpace(components=(2, 12)), components=5, random_state=0, contamination=0.1)#
Bases:
BaseModelConfigValidated hyperparameters of the reconstruction detector.
Fields mirror
Reconstruction’s constructor;spaceis the default Optuna search space. Build the detector withmake("detector", "reconstruction", ...)orReconstruction(**config.params()).Examples
>>> ReconstructionConfig().name 'reconstruction'