Contenido principal

detect

Detect anomalies in time series using trained deep learning detector model

Since R2025a

Description

Add-On Required: This feature requires the Time Series Anomaly Detection for MATLAB add-on.

detectionResults = detect(detector,data) detects subsequence anomalies in data using the trained deep learning anomaly detector detector and the subsequence length specified in the property detector.DetectionWindowLength. By default, the subsequences do not overlap.

detect calculates the anomaly scores, labels anomalies using the threshold value in the property detector.Threshold, and returns these labels and scores, as well as the window start indices, in detectionResults. A label of 1 indicates an anomaly and a label of 0 indicates no anomaly.

For an example of using detect as part of the detector development workflow, see Train and Test TCN Anomaly Detector.

This function requires Deep Learning Toolbox™.

detectionResults = detect(___,Name=Value) sets additional options using one or more Name=Value arguments. These options include execution-related specifications and the plotting of a histogram.

Input Arguments

collapse all

Trained deep learning anomaly detector model, specified as a TcnDetector, DeepantDetector, UsadDetector, or VaelstmDetector object.

Time series data to be evaluated for anomalies, specified as a matrix, a timetable, a cell array of matrices, or a cell array of timetables.

When data contains m sets of signals, each of which contain n = detector.NumChannels channels, the possible formats are these:

  • n-column matrix that consists of a single multichannel signal observation (m=1).

    A sufficiently long single observation can be as effective for training as multiple shorter observations.

  • Cell array with m cells that each contain a matrix or timetable that has NumChannels columns.

  • Timetable that contains a single multichannel signal observation, arranged in one of two possible ways.

    • The n channels are distributed in the columns of a matrix that the timetable contains in a single variable

    • The n channels are represented by n timetable variables that each contain a vector.

    In either case, the timetable must contain finite, increasing, and uniformly sampled time values.

Name-Value Arguments

expand all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: detectResults = (detectortcn,data,ExecutionEnvironment="cpu") specifies that the software use the CPU to perform the detection, whether or not a GPU is available.

All Deep Learning Detectors

expand all

Mini-batch size, specified as a positive integer scalar for network detection computations.

Option to plot a histogram of the anomaly scores, specified as false (no histogram or true (plot histogram).

Execution environment that determines what hardware resources the software uses to run the network, specified as "auto", "cpu", "gpu", or "multi-gpu".

  • "auto" — Use the GPU if one is available, or if not, the CPU.

  • "cpu" — Use the CPU.

  • "gpu" — Use the GPU.

  • "multi-gpu" — Use the GPU array.

Example: resultsUsad = detect(detectorUsad,trainData,ExecutionEnvironment="cpu") uses the CPU for detection regardless of whether a GPU is available.

Output Arguments

collapse all

Detection information for each window, returned as a table containing a column of tables, one table for each data channel. Each table within detectionResults contains the window anomaly labels, anomaly scores, and window start indices for the corresponding channel.

Extended Capabilities

expand all

Version History

Introduced in R2025a

expand all