I'm currently trying to classify discrete sequential data into five classes with machine learning.

The setup is the following: The actual object is filled with various properties, but to separate the objects and assign them to a class, it's necessary to look at the pattern of occurrence over a year. Therefore, I convert the objects to an array of 0- and 1's with a fixed length of 366.

Example: If the objects occur on the 1st and 3rd of January, the first elements of the sequence will look like this: [1, 0, 1, ... ]

So the data for each object would be a sequence of the fixed length of 366 and could look like this:

1 2 3 5 6 ... 365 366 Label
0 1 1 0 1 ... 0 1 A
1 1 1 0 0 ... 0 1 A
1 1 1 0 1 ... 0 1 B
0 1 0 0 0 ... 0 1 C
0 0 0 0 1 ... 0 1 A

So the goal would be to enter the sequences into a model to classify its class.

First question: I tried this pattern classification with a CNN and achieved an accuracy of up to 80%. But are there any other approaches to tackle this problem? It seems like a simple problem, so I'd expect a simple solution.

Second question: Let's say I wanted only to identify one of those classes. What should the setup look like? Just input data of that class?

  • $\begingroup$ Are all features sequential with a length of 366 or do you have other features? $\endgroup$ Jan 30, 2023 at 9:39
  • $\begingroup$ IMHO, your question is poorly written; please spend more time improving it. I am fond of time series analysis, but I have difficulties understanding your issue. $\endgroup$
    – Eduard
    Jan 30, 2023 at 17:36
  • 1
    $\begingroup$ @Eduard I improved the question a bit, I hope it's clear now. If not, please let me know. $\endgroup$
    – bitfish31
    Jan 31, 2023 at 14:09

1 Answer 1


The definition of your problem is univariate timeseries classification. Univariate because there is only one variable evolving through a time-axis, whereas multivariate is the case when you have more-than-one variable. It is crucial to stress it because these are the keywords to search for, in case of wondering.

By definition of timeseries, such objects can vary in length, which is the number of points. So, for example, in your scenario, there may be years where you have 366 days or 365, which complicates the modelling.

A simple, yet effective, solution to your problem and the one that I have noted is the following.$^\dagger$ You can use $k$-Nearest Neighbour equipped with a many-to-one alignment similarity measure, such as Dynamic Time Warping (DTW), to classify a new timeseries object exploiting such metric. The classifier is very simple to understand: there is no training time needed, the new instance is classified by looking at your training data for the $k$ most similar timeseries, and the class is a majority vote between the $k$ classes of the found objects (by the DTW algorithm).

The above (univariate) solution is discussed in this paper. If you are interested in approaches for the multivariate case, you can refer to this article, which are the same authors as the first one.

Finally, since the multivariate case generalizes the univariate one, in principle, you can use any solutions of the former for the latter.

$^\dagger$ I assume that you have basic understanding of $k$-Nearest Neighbour.


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.