Visualizing the Anomaly
Now let’s plot the anomalies which are predicted by the model and get a feel for whether the predictions made are correct or not by plotting the anomalous examples with red marks with the complete data.
Python3
# Plot the data with anomalies marked in red plt.figure(figsize = ( 16 , 8 )) plt.plot(data_converted[ 'timestamp' ], data_converted[ 'value' ]) plt.plot(data_converted[ 'timestamp' ][anomalous], data_converted[ 'value' ][anomalous], 'ro' ) plt.title( 'Anomaly Detection' ) plt.xlabel( 'Time' ) plt.ylabel( 'Value' ) plt.show() |
Output:
Anomaly Detection in Time Series Data
Anomaly detection is the process of identifying data points or patterns in a dataset that deviate significantly from the norm. A time series is a collection of data points gathered over some time. Anomaly detection in time series data may be helpful in various industries, including manufacturing, healthcare, and finance. Anomaly detection in time series data may be accomplished using unsupervised learning approaches like clustering, PCA (Principal Component Analysis), and autoencoders.