# Classify sequence of flags

I am not able to find an answer to how I should classify a varying number of sequence of binary flags + other features. My data looks like this (these are events, so the order is important and I may have other features in addition to sequence):

ID Flag 1 Flag 2 Flag 3 Other Feature
A 1 1 0 0.1
A 0 1 0 0.3
A 0 0 1 3.1
B 0 1 0 1.1
B 1 1 0 0.0

Notice that ID:B does not have the same number of entries (only 2). Any suggestion on how I should organize this data and what should I use to classify? How do I better capture the sequence of Flags? During inference, I will provide the sequence of flags [[1,1,0],[0,1,0],[0,0,1]] OR [[0,1,0],[1,1,0]] and "other feature" to get the label since the order of sequence makes up the positive or negative label.

• Can you please put your specific question in the title? Thanks. "Classify sequence of flags" is not really a question.
– nbro
Jun 1, 2023 at 8:35

You have a classification problem over a time-series, basically. You need to group all the events with the same ID under a single sequence, like [A, A, A] (is one sample) and [B,B] (is another).
Your targets ($$y$$) will be the class label, for each sequence and each element of the sequence. Then the $$x$$ will comprise the three flags and "other feature(s)" you have.
• Since you have sequences of the kind $$(B,T,N)$$ - where $$B$$ is the batch size, $$T$$ the num of events with same ID (you may need to zero-pad), and $$N$$ the number of features - and have a target for each $$t\in T$$, you need to predict the class label for each timestep $$T$$, and each sequence in $$B$$.
• So you're output won't be a single value for one input sequence but a sequence of values of size $$T$$.
• You can do that, but I was thinking about representing A as [[1, 1, 0, 0.1], [0, 1, 0, 0.3], [0,0,1,3.1]] so as a (1,3, 4) tensor, and B (with zero-pad) as [[1,1,0,0.1], [0,1,0,0.3], [0,0,0,0.0]]. You transform your dataset accordingly, then train a RNN by sampling $N$ of such sequences to build a mini-batch, and repeat that until convergence. Actually, if you provide masks to the RNN is as if having varying-length sequences. For example, the mask for B should be 1,1,0. To not consider the last timestep. Jun 2, 2023 at 10:20