MADRID as a Contract Algorithm�Demo of MADRID 2.0 version
Following is a real-world example to illustrate how to execute Contract MADRID on it.
MATLAB has a “deepSignalAnomalyDetector”
They demo it on this ECG, correctly noting…
The anomaly detection in this case is challenging because, as often happens in ECG recordings, the signal baseline drifts. These changes in baseline level can easily be misclassified as anomalies.
To solve this problem, they use training data, and they set 13 parameters.
However, using MADRID 2.0, we can solve this with fewer parameters!
https://www.mathworks.com/help/signal/ug/detect-anomalies-in-signals-using-deep-learning.html
MATLAB's ECG Example
Step 1: Download the data from https://ssd.mathworks.com/supportfiles/SPT/data/PhysionetSDDB.zip
https://www.mathworks.com/help/signal/ug/detect-anomalies-in-signals-using-deep-learning.html
MATLAB's ECG Example - Execution Demo
>> % Load data
datasetZipFile = matlab.internal.examples.downloadSupportFile('SPT','data/PhysionetSDDB.zip');
datasetFolder = fullfile(fileparts(datasetZipFile),'PhysionetSDDB');
if ~exist(datasetFolder,'dir')
unzip(datasetZipFile,datasetFolder);
end
ds2 = load(fullfile(datasetFolder,"sddb49.mat"));
ecgSignals2 = ds2.X;
ecgLabels2 = ds2.y;
dataProcessed = normalize(ecgSignals2);
T = dataProcessed.Variables;
>> % Set MADRID parameters
minL = 128;
maxL = 1024;
stepSize = 8;
train_test_split = 30000;
enable_output = 1;
Step 2: Download MADRID 2.0 from https://sites.google.com/view/madrid-icdm-23/documentation and set the parameters of MADRID
https://www.mathworks.com/help/signal/ug/detect-anomalies-in-signals-using-deep-learning.html
MATLAB's ECG Example - Execution Demo
>> % Set MADRID parameters
minL = 128;
maxL = 1024;
stepSize = 8;
train_test_split = 30000;
enable_output = 1;
Step 2: Download MADRID 2.0 from https://sites.google.com/view/madrid-icdm-23/documentation and set the parameters of MADRID
https://www.mathworks.com/help/signal/ug/detect-anomalies-in-signals-using-deep-learning.html
Set the minimum length of the anomaly to be searched.
MATLAB's ECG Example - Execution Demo
>> % Set MADRID parameters
minL = 128;
maxL = 1024;
stepSize = 8;
train_test_split = 30000;
enable_output = 1;
Step 2: Download MADRID 2.0 from https://sites.google.com/view/madrid-icdm-23/documentation and set the parameters of MADRID
https://www.mathworks.com/help/signal/ug/detect-anomalies-in-signals-using-deep-learning.html
Set the maximum length of the anomaly to be searched.
MATLAB's ECG Example - Execution Demo
>> % Set MADRID parameters
minL = 128;
maxL = 1024;
stepSize = 8;
train_test_split = 30000;
enable_output = 1;
Step 2: Download MADRID 2.0 from https://sites.google.com/view/madrid-icdm-23/documentation and set the parameters of MADRID
https://www.mathworks.com/help/signal/ug/detect-anomalies-in-signals-using-deep-learning.html
Set the step size of the search
MATLAB's ECG Example - Execution Demo
>> % Set MADRID parameters
minL = 128;
maxL = 1024;
stepSize = 8;
train_test_split = 30000;
enable_output = 1;
Step 2: Download MADRID 2.0 from https://sites.google.com/view/madrid-icdm-23/documentation and set the parameters of MADRID
https://www.mathworks.com/help/signal/ug/detect-anomalies-in-signals-using-deep-learning.html
Use the first 30,000 as training data and the rest as test data
MATLAB's ECG Example - Execution Demo
>> % Set MADRID parameters
minL = 128;
maxL = 1024;
stepSize = 8;
train_test_split = 30000;
enable_output = 1;
Step 2: Download MADRID 2.0 from https://sites.google.com/view/madrid-icdm-23/documentation and set the parameters of MADRID
https://www.mathworks.com/help/signal/ug/detect-anomalies-in-signals-using-deep-learning.html
If this parameter is set to 1, MADIRD is allowed to output the search results and report the execution time; if it is set to 0, any output is forbidden
MATLAB's ECG Example - Execution Demo
Step 3: Execute MADRID
MATLAB's ECG Example - Execution Demo
>> % Run MADRID
MADRID_2_0(T,minL,maxL,stepSize,train_test_split,enable_output);
1) Predicted execution time for MADRID 1 to 16: 4.3 seconds
2) Predicted execution time for MADRID 1 to 8: 13.2 seconds
3) Predicted execution time for MADRID 1 to 4: 46.7 seconds
4) Predicted execution time for MADRID 1 to 2: 285.1 seconds
5) Predicted execution time for MADRID 1 to 1: 2294.6 seconds
6) Quit
Please pick an option:
Step 4: Select the version to be executed based on the information provided in the interactive interface.
(If MADRID thinks it can converge in 10 seconds, it runs directly. Otherwise, MADIRD estimates the time required and pops up this interactive screen.)
MATLAB's ECG Example - Execution Demo
MATLAB's ECG Example - Execution Demo
Ground truth Location
MATLAB's ECG Example
This is the result of the MADRID 1 to 1 (using the raw data).
MATLAB's ECG Example
This is the result of the MADRID 1 to 2 (with downward sampling rate of 1/2).
It was ~6 times faster than the raw data , yet still successfully identified the ground truth anomaly.
Ground truth Location
MATLAB's ECG Example
This is the result of the MADRID 1 to 4 (with downward sampling rate of 1/4).
It was ~47 times faster than the raw data , yet still successfully identified the ground truth anomaly.
Ground truth Location
MATLAB's ECG Example
This is the result of the MADRID 1 to 8 (with downward sampling rate of 1/8).
It was ~274 times faster than the raw data , yet still successfully identified the ground truth anomaly.
Ground truth Location
MATLAB's ECG Example
This is the result of the MADRID 1 to 16 (with downward sampling rate of 1/16).
It was ~1518 times faster than the raw data, yet still successfully identified the ground truth anomaly.
Ground truth Location
Thanks for watching! Code and data are available in perpetuity from the MADRID page.
MADRID as a Contract Algorithm�Demo of MADRID 2.0 version