0
$\begingroup$

How to label time series so that we can train it on machine learning models to classify data point as anomaly or not?

If I have time series, and anomaly occurs at time t, should I label that point 1 and other points as 0, or there are any other methods to label the time series?

$\endgroup$
0
$\begingroup$

Anomaly or Outlier detection are usually used when we have cases that happens rarely. So it is not easy to gather data for those cases. Then what we do is, we just train with our normal data. It is also the same for time series.

It is usually falls under Unsupervised learning, as there is no need to label your data. You feed all the data that you have to the model (For example one Class SVM) and it would try to understand or find clusters/groups in the data. Afterwards for test data, it would give you a number as a result of prediction/detection. This number would represent how close or far this test data is to normal group/clusters.

Of course you should have labeled data for the propose of testing the model. For this case you can either generate anomaly data manually just for the sake of testing or you should identify some anomalies by analysing the data. Then you can test the model with these labeled data and see if it can actually recognise them or not.

Of course you can tackle this issue as two-class classification but then this is not anomaly detection anymore, and it will be a normal classification model.

Hope this helps.


For further info you can take a look at these:

https://scikit-learn.org/stable/modules/outlier_detection.html

https://scikit-learn.org/stable/modules/generated/sklearn.svm.OneClassSVM.html#sklearn-svm-oneclasssvm

$\endgroup$
  • $\begingroup$ I am dealing with streaming data here. When trained the model, I need to find when the next point arrives whether it is an anomaly or not. Do you know any sources or have any idea when detecting anomalies in such tie series? $\endgroup$ – Bhakti Aug 13 at 12:52
  • $\begingroup$ Did you already defined what is Anomaly in your data? This is the first thing to define. Regarding stream of data, you should still have some training data to train your model with it right? If so, you can just train your model as oneClass and send any upcoming data (from the stream) to your trained model for prediction. It should give you a distance as a result. Based on the distance number you should decide if it is an Anomaly or not. This is why I said you should define what is anomaly in your data, then decide from which distance it is considered anomaly. $\endgroup$ – Sean Mirchi Aug 13 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.