# Anomaly detection with time series

I have to study the behavoiur of a machine during its works: I have available time series of pressure, temperature and other physical measures for each work it is performing, I would like to predict errors or failures but till now they have not been recorded yet. So I thought to using these time series to understand if there are abnormal behaviours (which could lead to a faillure), maybe clustering time series. Beacuse I suppose that the machine, in normal condition, has the same parameters for each work. Is there a procedure/documentation/ best practises in order to do anomaly detecion with time series? Thanks a lot!

• I think yours is a good way of thinking: having no data of failure but searching for irregular behaviours. Let's expand irregular behaviours: If you visualize the statistical distribution of your features, you will see that there are some distributed as a group, whereas some are far away from the distribution. Those are outliers. If you can find a good rule of separating the outliers (95% confidence interval as example), you can label them as 'irregular' for using in a supervised algorithm. You can use DNN for this task. To start, you can use df.describe() of pandas for statistics of features. – Ugur MULUK Dec 12 '18 at 18:40

You can extract features from timeseries sliding window, eg. mean, std, etc etc, and then use these as features into your model for anomaly detection

Nice question. I can tell you two possible approaches from my experience with sensor data coming from IoT devices (in the industrial sector). Assuming you have several signals over time (temperature, pressure, torque...), you might be interested in:

• estimating whether a single data sample (i.e. 1 row of X signals values) is normal or an anomaly

• resampling your time series to a lower frequency applying summary statistics for each of the new resampled package of signals (e.g. from the original signals frequency in seconds to a new minutes interval); in this case, there is a nice package called tsfresh (time series fresh), as this creates an inmense group of new attributes for each resampled signal (e.g. median, std, min, max... for each minute interval of each signal)...

Once the preprocessing is done, you could apply models like OC-SVM (one-class support vector machine), IF (isolation forest)... as semi-supervised learning strategy (i.e. knowing the data of the normal behaviour, create a model which can detect anomalies far from this behaviour).

It's good u dont have any fault so far. You can build a normal model. may be relation of temprature with other variables. you can use regression or NN anything. Any deviation from established relation may be an abnormality.-

this earlier post might give more insights-

Looking for good package for anomaly detection in time series