I have this two dataset(image below).The one on the left shows events and the right is the alarm data.
Goal : Using the two datasets, after any number of events, an alarm can be triggered.I'd like to predict when the next alarm will rise.

enter image description here

Approach : I am a bit confused about the approach though. This is like a time-series data. Is using RNN the best approach or is there other approaches ?



1 Answer 1


This is sort of a hybrid task. It is time series data, but the outcome is categorical (it's binary in fact, it's whether the alarm is triggered (1), or the alarm is not triggered (0)). What you need here is a combination of a classifier and something that takes in sequential data.

As you said, I think an LSTM RNN fits the bill. If you use tensorflow and you need some initial model to start playing around with, you can just use a tensorflow.keras sequential model with the following in order:

  1. LSTM layer
  2. dropout or dense layers of choice (don't do anything too polarizing, maybe a modest dropout depending on how big your data is)
  3. output should be a dense layer, with an activation function of either sigmoid (number of units = 1) or softmax (number of units = 2)
  4. When you compile the models, use the following loss functions:
  • if you chose sigmoid, use binary crossentropy
  • if you chose softmax, use categorical crossentropy (if your labels are one-hot encoded), use sparse categorical crossentropy (if your labels are just integers)

If you use PyTorch instead, then you can find a direct analogue to what I described.

Make sure to label your data at every timestep (whether the alarm rang or not), and check if the dataset is imbalanced and judge your model thoroughly using precision, recall, f1 score. Accuracy is misleading for imbalanced data. I hope this gives you a good direction to start the analysis.

  • $\begingroup$ Thanks for the detailed answer. "Make sure to label your data at every timestep (whether the alarm rang or not)" This line was the missing context in my understanding, Now it makes sense. $\endgroup$
    – mehmat
    Commented Apr 13, 2022 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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