Anomaly Detection Shiny App
Contributed by Kyle Szela. He is currently in the NYC Data Science Academy 12 week full time Data Science Bootcamp program taking place between April 11th to July 1st, 2016. This post is based on his second class project - Shiny App (due on the 4th week of the program).
My initial idea for a shiny app was to take ECG data (the recordings of electrical and muscular activity of the heart) and apply anomaly detection with seasonal periodicity taken into account. Unfortunately, the mutation of the dataset into an acceptable time series proved extremely difficult. So difficult, that I wanted to make it easier for others to be able to perform this time series anomaly detection easily. The end result is an app that will take in a dataset and attempt to perform the associated anomaly detection algorithm despite time series data that is not easily cast to a R compatible format.
Uploading and Viewing the Dataset:
The first tab, shown below, allows for the uploading of a dataset into the app. It allows the user to specify the inclusion of the header, the delimiter, and the type of quotation of the .csv file. The user simply clicks the "Choose File" button, finds their csv file, and uploads it.
Once the dataset is uploaded, the app will attempt to cast the first column into a timestamp format. If it is not able to do this, it will cast the sample number into a time series, instead, and will display the old data as a third column. The corresponding time series graph will be presented in the "Data Chart" section, while the csv data will be presented in table format in the "Data" section.
The next tab allows the user to filter his or her data with either a Butterworth or a Type-II Chiebyshev filter. The idea behind these filters is that they allow the user to partially select the different anomalies to detect, as well as remove noise from the dataset and aid in the visualization of the time series data. Choosing not to filter the data will not remove the ability to perform the time series anomaly detection. I've found that the Butterworth filter does a pretty great job of smoothing out the dataset.
The last tab allows the user to detect anomalous points in their dataset. In the "Settings" section, there are a few different options for the user to choose. The "Max % of Anomalies" refers to the maximum number of anomalous points to be found, as a percentage of the total data set. The "alpha" refers to the statistical significance required for each point to be considered an anomaly. Lastly, the "Direction" radio buttons allow the user to choose if they would like to find only the positive, negative, or both directional anomalies.
Once the user has selected their settings, and the "Filter" button has been pressed, a graph is displayed in the "Data Chart" section that affords the ability to pinpoint the individual anomalous points in the time series. Additionally, these points will be presented in table format in the "Data" section, and are available for download.