I've got an array of integers ranging from -3 to +3.

Example: [1, 3, -2, 0, 0, 1]

The array has no obvious pattern since it represents bipolar disorder mood swings.

What is the most suitable approach to predict the next number in the series? The length of the array is about 700 entries.

From where can I start the investigation? (provided that I've got some experience in Python and Node.js, but only a hello-worldish acquaintance with TensorFlow). Which training model might be suitable in this case? How can I chunk the data set properly?

  • 1
    $\begingroup$ Just to clarify, do you only have 700 observations or do you have n sets of 700 observations? $\endgroup$
    – Akavall
    Commented Oct 4, 2021 at 22:54
  • $\begingroup$ Thanks for the question! It's 700 observations only $\endgroup$
    – ZenBerry
    Commented Oct 5, 2021 at 4:58
  • 7
    $\begingroup$ Keep in mind that "no obvious pattern" may actually mean "no pattern at all", in which case the answer to "how can I predict the next number?" is "you can't". It's worth trying, but some sequences will be impossible to predict. $\endgroup$ Commented Oct 5, 2021 at 13:52
  • 1
    $\begingroup$ have you seen this recent video from mathloger? They address this question: youtube.com/watch?v=4AuV93LOPcE $\endgroup$
    – Our
    Commented Oct 5, 2021 at 18:44

4 Answers 4


As all you have is a series of numbers, you should try using a sequence model. I suggest you look into RNNs and in particular LSTMs. Of course this is assuming despite the lack of "obvious patterns", there are some kind of hidden patterns in your data. If not, what you have is not very different than random walk in 3 dimensions - which makes the case unpredictable in the first place.


This is a question of time series forecasting, since your numbers form a sequence. You may want to take a look at the "forecasting" tag at CrossValidated.

If you have only 700 data points, ML/AI methods will likely not be very useful. Whatever you do, I would recommend you benchmark your chosen method against very simple approaches, like the overall mean, or the last observation (a "random walk forecast"), or a simple Exponential Smoothing method. These very simple benchmarks can often be surprisingly hard to beat, and they are trivially easy to set up.

You next step should be to include domain knowledge, as Sanyou recommends. This can be as simple as observing that bipolar mood swings follow a day/night cycle and modeling this seasonality, e.g., in a seasonal Exponential Smoothing method. (I'm not saying this disorder does exhibit this kind of seasonality, only that if it does, this can easily be modeled.) Or model any other kinds of drivers you know.

In my experience, understanding your data and your context always beats building more fancy models, or collecting more data.

As free time series forecasting textbooks, I very much recommend Forecasting: Principles and Practice (2nd ed.) by Athanasopoulos & Hyndman and Forecasting: Principles and Practice (3rd ed.) by Athanasopoulos & Hyndman.


I guess the most "suitable" approach is to look up research papers on ML/AI/Stats based methods on bipolar disorder mood swings prediction/regression etc. Focus on the abstract, intro/related works and conclusion. Find out why the method is proposed, what the well-known approaches are, what the intuition for the proposed methods are. Find out the fundamental resources cited on the intro/related works. From the intro and related works, look up the references and skim them.

As for the theoretical basis, the math and the proposed method, just skim them quick, next time you got time/the feels you can deepen them. Utilize sci-hub or lib-gen or similar webs if you/your institution is not subscribed to the publishers. Bonus points: some papers also include github/links to their implementation source code.

Quick search on google scholar with the query "bipolar mood swing prediction machine learning" resulted in cool (at least the titile) research papers. For example The impact of machine learning techniques in the study of bipolar disorder: a systematic review, and Review on Machine Learning Techniques to predict Bipolar Disorder.

Why do we go with this approach? Because your domain is specific, vast and complex it its own way. Most of the time, they already tried the "basics" prediction/regression/classification on your domain and published the methods as well as the results, so you can start from there and gain even more because of the additional knowledges/references from the papers.


Since you only have only 700 observations, I would not try a deep learning approach. I think it is very unlikely that any Deep Learning approach will learn a non-obvious relationship with that little data.

What you could try is create a set of features based on lags. Create a feature, that is lagged by 1, by 2, by 3, and so on. Also moving average of lagged variables could be useful, window of 2,3,5. Standard deviation could also be interesting, though at bit larger windows. And then train a regular ML model.

I would try this simple approach even if I had 10 million observations, and planned on using Deep Learning, so I could use it as a benchmark.

  • $\begingroup$ Rather than using hand-crafted features using lags, I'd start with a plain old auto-regressive (AR) model, perhaps then auto-regressive moving-average (ARMA). $\endgroup$ Commented Oct 5, 2021 at 23:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .