Home
%3CLINGO-SUB%20id%3D%22lingo-sub-982798%22%20slang%3D%22en-US%22%3EOverview%20of%20SR-CNN%20algorithm%20in%20Azure%20Anomaly%20Detector%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-982798%22%20slang%3D%22en-US%22%3E%3CP%3EAuthor%3A%20Tony%20Xing%20(%40XingGuodong)%2C%26nbsp%3BAI%20Platform%2C%20C%20%2B%20AI%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20last%20blog%20%E2%80%9C%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAI-Customer-Engineering-Team%2FIntroducing-Azure-Anomaly-Detector-API%2Fba-p%2F490162%22%20target%3D%22_self%22%3EIntroducing%20Azure%20Anomaly%20Detector%20API%3C%2FA%3E%E2%80%9D%2C%20I%20didn't%20provide%20enough%20details%20on%20one%20of%20the%20algorithms.%20As%20the%20algorithm%20paper%20was%20in%20the%20publishing%20process.%20The%20paper%20was%20accepted%20by%20KDD%202019%20for%20oral%20presentation%20later%2C%20and%20this%20blog%20serves%20as%20an%20overview%20of%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.kdd.org%2Fkdd2019%2Faccepted-papers%2Fview%2Ftime-series-anomaly-detection-service-at-microsoft%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESR-CNN%20algorithm%3C%2FA%3E%20and%20for%20more%20details%20user%20can%20always%20read%20the%20%3CA%20href%3D%22https%3A%2F%2Farxiv.org%2Fabs%2F1906.03821%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epaper%3C%2FA%3E.%20By%20the%20way%2C%20we%20have%20a%202-minute%20video%20here.%3C%2FP%3E%3CDIV%20class%3D%22video-embed-center%20video-embed%22%3E%3CIFRAME%20class%3D%22embedly-embed%22%20src%3D%22https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252FERTaAnwCarM%253Ffeature%253Doembed%26amp%3Burl%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DERTaAnwCarM%26amp%3Bimage%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252FERTaAnwCarM%252Fhqdefault.jpg%26amp%3Bkey%3Dfad07bfa4bd747d3bdea27e17b533c0e%26amp%3Btype%3Dtext%252Fhtml%26amp%3Bschema%3Dyoutube%22%20width%3D%22200%22%20height%3D%22112%22%20scrolling%3D%22no%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%20title%3D%22Video%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%3CP%3E%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-2048954184%22%20id%3D%22toc-hId-2048954184%22%20id%3D%22toc-hId-2048954184%22%3EProblem%20definition%3C%2FH1%3E%0A%3CP%3EBefore%20we%20go%20into%20details%2C%20let%20us%20revisit%20the%20problem%20definition%20of%20time%20series%20anomaly%20detection.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154842i3506C7B172BF9D9B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154843iE9E14B591163B62C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--503202777%22%20id%3D%22toc-hId--503202777%22%20id%3D%22toc-hId--503202777%22%3EChallenges%3C%2FH1%3E%0A%3CP%3EFor%20any%20time-series%20anomaly%20detection%20system%20that%20is%20operating%20in%20production%20with%20a%20large%20scale%2C%20there%20are%20quite%20a%20few%20challenges%2C%20especially%20on%20the%20three%20areas%20below%3A%3C%2FP%3E%0A%3CP%3E1.%20Lack%20of%20labels%20-%20As%20you%20can%20imagine%2C%20with%20signals%20generated%20from%20clients%2C%20services%2C%20and%20sensors%20every%20second%2C%20the%20huge%20amount%20of%20volume%20makes%20it%20infeasible%20to%20manually%20label%20the%20data.%3C%2FP%3E%0A%3CP%3E2.%20Generalization%20-%26nbsp%3BWith%20real-world%20data%2C%20there%20are%20so%20many%20different%20types%20of%20time%20series%20with%20different%20characteristics%2C%20which%20make%20it%20hard%20to%20generalize%20and%20find%20a%20silver%20bullet%20to%20solve%20all%20the%20problems.%20Some%20examples%20can%20be%20found%20in%20the%20figure%20below.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154844i9A810F122D4586A5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_2.png%22%20title%3D%22clipboard_image_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E3.%20Efficiency%20-%26nbsp%3BFor%20any%20online%20anomaly%20detection%20system%2C%20efficiency%20is%20one%20of%20the%20key%20challenges.%20The%20system%20is%20expected%20to%20have%20low%20compute%20cost%20and%20low%20latency%20for%20serving.%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-1239607558%22%20id%3D%22toc-hId-1239607558%22%20id%3D%22toc-hId-1239607558%22%3EInspiration%3C%2FH1%3E%0A%3CP%3EIn%20the%20computer%20vision%20domain%2C%20there%20is%20this%20concept%20called%20%E2%80%9Cvisual%20saliency%20detection%E2%80%9D.%20Saliency%20is%20what%20%22stands%20out%22%20in%20a%20photo%20or%20scene%2C%20enabling%20our%20eye-brain%20to%20quickly%20focus%20on%20the%20most%20important%20regions%2C%20as%20shown%20in%20figures%20below.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20531px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154845i4C9941124AF346ED%2Fimage-dimensions%2F531x270%3Fv%3D1.0%22%20width%3D%22531%22%20height%3D%22270%22%20alt%3D%22clipboard_image_3.png%22%20title%3D%22clipboard_image_3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFig.%20Original%20image%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20532px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154846iAAD1FD3D48125088%2Fimage-dimensions%2F532x269%3Fv%3D1.0%22%20width%3D%22532%22%20height%3D%22269%22%20alt%3D%22clipboard_image_4.png%22%20title%3D%22clipboard_image_4.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFig.%20The%20salient%20part%20of%20the%20original%20image%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20we%20look%20at%20the%20time%20series%20chart%2C%20the%20most%20dominant%20and%20stand-out%20part%20is%20the%20anomalies.%20This%20similarity%20is%20where%20we%20got%20the%20inspiration%20and%20it%20turned%20out%20to%20generate%20great%20results.%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1312549403%22%20id%3D%22toc-hId--1312549403%22%20id%3D%22toc-hId--1312549403%22%3EAlgorithm%3C%2FH1%3E%0A%3CP%3EOur%20solution%20then%20borrowed%20Spectral%20Residual%20(SR)%20from%20the%20visual%20saliency%20detection%20domain%2C%20then%20apply%20CNN%20on%20the%20results%20produced%20by%20the%20SR%20model%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154847i7C489F3FFE63E547%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_5.png%22%20title%3D%22clipboard_image_5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%20from%20the%20algorithm%20architecture%2C%20after%20SR%20transformation%2C%20the%20transformed%20result%20magnifies%20the%20anomalies%20and%20the%20resulting%20signal%20is%20easier%20to%20generalize%2C%20therefore%20it%20provides%20us%20a%20way%20to%20training%20CNN%20with%20synthetic%20data.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-233747427%22%20id%3D%22toc-hId-233747427%22%20id%3D%22toc-hId-233747427%22%3ESpectral%20Residual%3C%2FH2%3E%0A%3CP%3EThe%20spectral%20residual%20algorithm%20consists%20of%20three%20major%20steps%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EFourier%20Transform%20to%20get%20the%20log%20amplitude%20spectrum%3C%2FLI%3E%0A%3CLI%3ECalculation%20of%20spectral%20residual%3C%2FLI%3E%0A%3CLI%3EInverse%20Fourier%20Transform%20that%20transforms%20the%20sequence%20back%20to%20the%20spatial%20domain%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154848i26E058275AB44D2C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_6.png%22%20title%3D%22clipboard_image_6.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1976557762%22%20id%3D%22toc-hId-1976557762%22%20id%3D%22toc-hId-1976557762%22%3EBenefits%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3ESR%20is%20unsupervised%2C%20efficient%2C%20and%20has%20good%20generality.%3C%2FLI%3E%0A%3CLI%3EThe%20problem%20becomes%20much%20easier%20based%20on%20the%20output%20of%20the%20SR%20model.%3C%2FLI%3E%0A%3CLI%3EWe%20can%20train%20CNN%20on%20the%20SR%20output%20using%20fully%20synthetic%20data%20with%20simple%20synthetic%20rule%3CUL%3E%0A%3CLI%3ERandomly%20select%20several%20points%20in%20the%20saliency%20map%20and%20calculate%20the%20injection%20value%20to%20replace%20the%20original%20point.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154849i468AF49444941BF3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_7.png%22%20title%3D%22clipboard_image_7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--379085694%22%20id%3D%22toc-hId--379085694%22%20id%3D%22toc-hId--379085694%22%3EResult%3C%2FH1%3E%0A%3CP%3EWe%20have%20performed%20online%20and%20offline%20experimentation%2C%20it%20outperformed%20state-of-the-arts%20consistently%20on%20open%20datasets%20and%20internal%20production%20datasets.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F154850iAEEF9CFD6F195549%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_8.png%22%20title%3D%22clipboard_image_8.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-982798%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAnomaly%20Detection%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAnomaly%20Detector%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzureAI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECognitive%20Services%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1037402%22%20slang%3D%22en-US%22%3ERe%3A%20Overview%20of%20SR-CNN%20algorithm%20in%20Azure%20Anomaly%20Detector%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1037402%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20sharing%20this.%20I%20find%20anomaly%20detection%20particularly%20interesting%20as%20it%20changes%20the%20way%20I%20play%20cards%20(when%20its%20my%20brain%20detecting%20the%20anomalies).%20I%20factor%20in%20variable%20change%20and%20its%20affect%20on%20the%20probable%20outcomes%20when%20making%20strategic%20decisions.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

Author: Tony Xing (@XingGuodong), AI Platform, C + AI

 

In the last blog “Introducing Azure Anomaly Detector API”, I didn't provide enough details on one of the algorithms. As the algorithm paper was in the publishing process. The paper was accepted by KDD 2019 for oral presentation later, and this blog serves as an overview of the SR-CNN algorithm and for more details user can always read the paper. By the way, we have a 2-minute video here.

Problem definition

Before we go into details, let us revisit the problem definition of time series anomaly detection.

clipboard_image_0.png

clipboard_image_1.png

Challenges

For any time-series anomaly detection system that is operating in production with a large scale, there are quite a few challenges, especially on the three areas below:

1. Lack of labels - As you can imagine, with signals generated from clients, services, and sensors every second, the huge amount of volume makes it infeasible to manually label the data.

2. Generalization - With real-world data, there are so many different types of time series with different characteristics, which make it hard to generalize and find a silver bullet to solve all the problems. Some examples can be found in the figure below.

clipboard_image_2.png

3. Efficiency - For any online anomaly detection system, efficiency is one of the key challenges. The system is expected to have low compute cost and low latency for serving.

Inspiration

In the computer vision domain, there is this concept called “visual saliency detection”. Saliency is what "stands out" in a photo or scene, enabling our eye-brain to quickly focus on the most important regions, as shown in figures below.

clipboard_image_3.png

Fig. Original image

clipboard_image_4.png

Fig. The salient part of the original image

 

When we look at the time series chart, the most dominant and stand-out part is the anomalies. This similarity is where we got the inspiration and it turned out to generate great results.

Algorithm

Our solution then borrowed Spectral Residual (SR) from the visual saliency detection domain, then apply CNN on the results produced by the SR model

clipboard_image_5.png

As you can see from the algorithm architecture, after SR transformation, the transformed result magnifies the anomalies and the resulting signal is easier to generalize, therefore it provides us a way to training CNN with synthetic data.

 

Spectral Residual

The spectral residual algorithm consists of three major steps:

 

  1. Fourier Transform to get the log amplitude spectrum
  2. Calculation of spectral residual
  3. Inverse Fourier Transform that transforms the sequence back to the spatial domain

clipboard_image_6.png

Benefits

  • SR is unsupervised, efficient, and has good generality.
  • The problem becomes much easier based on the output of the SR model.
  • We can train CNN on the SR output using fully synthetic data with simple synthetic rule
    • Randomly select several points in the saliency map and calculate the injection value to replace the original point.

clipboard_image_7.png

Result

We have performed online and offline experimentation, it outperformed state-of-the-arts consistently on open datasets and internal production datasets.

clipboard_image_8.png

 

1 Comment
New Contributor

Thanks for sharing this. I find anomaly detection particularly interesting as it changes the way I play cards (when its my brain detecting the anomalies). I factor in variable change and its affect on the probable outcomes when making strategic decisions.