1 of 27

MADRID as a Contract AlgorithmDemo of MADRID 2.0 version

2 of 27

  • Although MADRID is a highly optimized algorithm in terms of speed, it can also be further adapted to become a contract algorithm.

3 of 27

  • Although MADRID is a highly optimized algorithm in terms of speed, it can also be further adapted to become a contract algorithm.

  • What is a contract algorithm?

4 of 27

  • Although MADRID is a highly optimized algorithm in terms of speed, it can also be further adapted to become a contract algorithm.

  • What is a contract algorithm?
    • It is an algorithm designed to produce the best possible solution within the allotted time. It means the algorithm is given a specified amount of time to run before it starts.

5 of 27

  • Although MADRID is a highly optimized algorithm in terms of speed, it can also be further adapted to become a contract algorithm.

  • What is a contract algorithm?
    • It is an algorithm designed to produce the best possible solution within the allotted time. It means the algorithm is given a specified amount of time to run before it starts.

  • Why do we need a contract version of MADRID?

6 of 27

  • Why do we need a contract version of MADRID?
    • Contract MADRID affords users the flexibility to plan their computational resources based on their availability of time/memory/etc.

7 of 27

  • Why do we need a contract version of MADRID?
    • Contract MADRID affords users the flexibility to plan their computational resources based on their availability of time/memory/etc.
    • The accuracy of Contract MADRID is largely maintained, only weakly affected by downsampling of input.

8 of 27

  • Why do we need a contract version of MADRID?
    • Contract MADRID affords users the flexibility to plan their computational resources based on their availability of time/memory/etc.
    • The accuracy of Contract MADRID is largely maintained, only weakly affected by downsampling of input.
    • Contract MADRID saves memory significantly, with storage requirements decreasing at a quadratic rate.

9 of 27

  • Why do we need a contract version of MADRID?
    • Contract MADRID affords users the flexibility to plan their computational resources based on their availability of time/memory/etc.
    • The accuracy of Contract MADRID is largely maintained, only weakly affected by downsampling of input.
    • Contract MADRID saves memory significantly, with storage requirements decreasing at a quadratic rate.

  • The 2.0 version of MADRID introduces an interactive interface, which presents users with a choice of execution times for Contract MADRID. This allows users to make informed choices based on their computational budgets.

10 of 27

Following is a real-world example to illustrate how to execute Contract MADRID on it.

11 of 27

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

12 of 27

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;

13 of 27

>> % 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

14 of 27

>> % 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

15 of 27

>> % 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

16 of 27

>> % 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

17 of 27

>> % 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

18 of 27

>> % 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

19 of 27

Step 3: Execute MADRID

MATLAB's ECG Example - Execution Demo

>> % Run MADRID

MADRID_2_0(T,minL,maxL,stepSize,train_test_split,enable_output);

20 of 27

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

21 of 27

MATLAB's ECG Example - Execution Demo

22 of 27

Ground truth Location

MATLAB's ECG Example

This is the result of the MADRID 1 to 1 (using the raw data).

23 of 27

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

24 of 27

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

25 of 27

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

26 of 27

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

27 of 27

Thanks for watching! Code and data are available in perpetuity from the MADRID page.

MADRID as a Contract AlgorithmDemo of MADRID 2.0 version