DiffDetector

DiffDetector(max_diff=np.inf, direction='both')

Detect sudden shifts in data, irrespective of time axis.

Parameters

Name Type Description Default
max_diff float Maximum change threshold between consecutive points. np.inf
direction (both, positive, negative) Direction of change to detect. ‘positive’ detects only increases, ‘negative’ detects only decreases, ‘both’ detects changes in either direction. 'both'

See Also

GradientDetector : Similar functionality but considers actual time between data points.

Methods

Name Description
detect Detect anomalies
fit Set detector parameters based on data.
save Save a detector for later use.
validate Check that input data is in correct format and possibly adjust.

detect

DiffDetector.detect(data)

Detect anomalies

Parameters

Name Type Description Default
data Union[pd.Series, pd.DataFrame] Time series data with possible anomalies required

Returns

Name Type Description
pd.Series or pd.DataFrame Time series with bools, True == anomaly.

fit

DiffDetector.fit(data)

Set detector parameters based on data.

Parameters

Name Type Description Default
data Union[pd.Series, pd.DataFrame] Normal (non-anomalous) time series data for training. If DataFrame, must contain exactly one column required

Returns

Name Type Description
Self

save

DiffDetector.save(path)

Save a detector for later use.

Parameters

Name Type Description Default
path str or Path File path to save the detector to. required

validate

DiffDetector.validate(data)

Check that input data is in correct format and possibly adjust.

Parameters

Name Type Description Default
data pd.Series or pd.DataFrame Input data to validate. required

Returns

Name Type Description
pd.DataFrame Validated data.

Raises

Name Type Description
WrongInputDataTypeError If data is not a pd.Series or pd.DataFrame.