zoo.zouwu.model package¶
Submodules¶
zoo.zouwu.model.anomaly module¶
-
class
zoo.zouwu.model.anomaly.EuclideanDistance[source]¶ Bases:
zoo.zouwu.model.anomaly.DistanceEuclidean Distance Measure
-
class
zoo.zouwu.model.anomaly.ThresholdDetector[source]¶ Bases:
zoo.zouwu.model.anomaly.DetectorBaseAnomaly detector
-
detect(y, yhat=None, threshold=inf, dist_measure=<zoo.zouwu.model.anomaly.EuclideanDistance object>)[source]¶ Detect anomalies. Each sample can have 1 or more dimensions. :param dist_measure: :param y: the values to detect. shape could be
1-D (num_samples,) or 2-D array (num_samples, features)Parameters: - yhat – the estimated values, a tensor with same shape as y, could be None when threshold is a tuple
- threshold – threshold, could be 1. a single value - absolute distance threshold, same for all samples 2. a 1-D array in shape (num_samples,) - per sample absolute distance threshold 3. a tensor in same shape as y and yhat - per dimension absolute distance threshold 4. a tuple (min, max) min and max tensors, same shape as y, yhat is ignored in this case
Returns: the anomaly values indexes in the samples, i.e. num_samples dimension.
-
-
class
zoo.zouwu.model.anomaly.ThresholdEstimator[source]¶ Bases:
objectAn estimator to find the proper threshold.
-
fit(y, yhat, mode='default', ratio=0.01, dist_measure=<zoo.zouwu.model.anomaly.EuclideanDistance object>)[source]¶ fit the y and yhat and find the proper threshold :param y: actual values :param yhat: predicted values :param mode: types of ways to find threshold
“default” : fit data to a uniform distribution (the percentile way) “gaussian”: fit data to a gaussian distribution *TBDParameters: ratio – the ratio of anomaly to consider as anomaly. Returns: the threshold
-