# Classification methods for univariate time series

Our team wants to develop a machine learning algorithm for classification of univariate data. Our data is a live feed from a position sensor placed in an injection molding machine. We want to be able to clearly identify the number of cycles this machine makes. The data has a timestamp (every 100 ms approximately) and a 'position' value. We are acquiring the data and processing it with a Raspberry pi 4, so we hoped we could perform all processing on it. In the data series we have primarily two values/positions:

• High value: When the injection molding machine is using its clamping force to close the mold.
• Low value: When the mold is opened.

Relative to the interactions of these values, we will have different events. When it goes up a certain time and then down, there will be a cycle. When it stays either up or down for a longer time means that the machine was stopped. When it goes up and down in a short time could mean that the operator of the machine was performing a dry cycle (no injection, just moving the plates of the machine, for example).

I know this simple problem could be solved via a heuristic approach, but we want to be able to develop a method for this in order to learn and put our hands in more complex models. And also, our current heuristic approach fails when there are unidentified cycle movements, so we hoped to make it more robust with better algorithms.

What we've found so far

My research has lead me into thinking LSTMs with sliding windows could help me perform this task:

1. I could perform a cluster operation on a static window in order to know how long the window size (e.g. number of timestamps to take into account) should be (for example, creating clusters between position data and time elapsed in this position). This could be made once in a while to adjust the window in case someone changes the mold in the machine (this situation would result in a different cycle time because it would be a different molded product).
2. With the time window known, I could use a sliding window to perform a classification between cycle/no cycle/idle and be able to count this in order to know how many cycles where performed in certain time.

The previous approach is just a possible example of what i believe we could do. I have encountered several possible methods but RNNs and LSTMs are a frequent subject in classification for time series. Maybe this is not the best approach, maybe it could be a good one. That's our doubt and will be our starting point in this learning (human learning!) process. Therefore, today i'm coming to you because i believe i could get your opinions in terms of:

• Do you think this sort of algorithm would work properly for our application?
• Do you think there might be a simpler approach which we could use?
• Relative to the approach (either the one proposed or another one you think would suit better this particular application), do you think a raspberry pi 4 could be enough to perform these classifications in real time?

I have plenty of sample data which i could use for training and labeling every event in different stages of the process. Every opinion of yours is greatly appreciated. Thank you!

• RNN/LSTM is the obvious first idea. Another is to do a wavelet transform (or similar) of the time series to make it photo-like and run a convolutional neural network. Brandon Rohrer mentions this in his excellent video on CNNs: youtube.com/watch?v=FmpDIaiMIeA&t=1321s. This CNN approach can be combined with RNN/LSTM, too.
– Dave
Commented Nov 28, 2019 at 14:58
• Thanks for your answer Dave. That's an interesting approach, I thought about it but I had some doubts whether it could be heavy to run on a raspberry. Another one of my doubts was how to slice the real time data so that I could build these images from similar time/position behaviors. If there are events that could take a longer time than others, that could start at different times relative to the chosen analysis window, how could one isolate this effect? I believe from this approach a fixed size window could be an issue... Commented Nov 28, 2019 at 17:32
• Unequal data size presents a problem, and I’m pretty sure you don’t avoid it by doing straight RNN/LSTM instead of CNN-LSTM. Since you have a live feed, I assume you’ll only be looking at the past X-many seconds. Perhaps start by training your models on some restricted amount of data (5 seconds, 30 minutes, whatever seems to matter). You can figure out what the correct duration is empirically and with some subject matter expertise. Then your live feed can give that duration to a trained model to make the predictions.
– Dave
Commented Nov 28, 2019 at 17:58