# Estimate battery voltage based on scheduled events and previous behaviour

My goal is to estimate if a battery will have enough charge for certain other systems to be powered. The power state of the other systems is recorded (i.e. if they are turned on or not), as well as the times when the battery is being charged by solar panel during sunlight. These records are several month in the past.

My question is now, in what topic/algorithms should I research when I want to use the previous data and events to estimate/extrapolate the voltage into the future (to make scheduling of powering systems easier, such as canceling them if the battery will be drained too much)? The upcoming charging times can be calculated, and it'll also be known when a system will be powered.

All the datasets (i.e. voltage, charging times, events) are available as timeseries (but with different timestamps/sample rates).

One of the simplest ways to get to some predictions would be to use a model like ARIMA, which looks at recent previous observations to predict a number of steps ahead. ARIMA stands for Autoregressive Integrated Moving Average:

• Autoregressive means that something looks at its own (auto) historical values
• Integrated refers to the _differencing, a step tp help remove non-stationarity
• Moving Average just means the model also takes the moving average into account (helps keep predictions in reasonable ball park)

Here is a good little explanation of the main points in more detail.

In your case, given there are factors such as weather and time of data to be used, you would probably benefit from using seasonality. For this there is an extended ARIMA, called SARIMA - where S stands for seasonal. There is an implementation in Python's statsmodels package - or if you want to use R, then maybe take a look at the forecast package by the great Rob Hyndman, or the sarima package.

If you want to use something a little more modern and cutting edge, then you are really talking about Recurrent Neural Networks (RNNs). I am not sure how familiar you are with there? One key term you should understand: LSTM - a type of unit that considers past data, current data and maintains a state of your model at a specific point in time.

Have a look at a walkthrough (example) to see if it makes sense to you.

ARIMA type models are easy to get running and the results are easy to interpret, so you really know what is going on. The performance of things like RNNs should be better, but it is rarely a short walk to success... of course it will depend on your data.

• Is it true that LSTM is only used for short dataset means around 3000 samples. Like the minimum temperature collected over 12 years for each day? – baddy Feb 19 at 9:10
• You can use an LSTM over a really long dataset in general; the important part is how long the input sequence is at each step. If you want to use the previous 60 days to predict tomorrow, that should be fine. Adding 3000 previous steps likely won't help the model, and might hurt performance. Attention-based models have shown to be better at storing longer sequences, but there is typically then a memory problem as the memory requirement grows quadratically with the model's attention matrix (so input size). – n1k31t4 Feb 19 at 10:09
• How I choose my steptime if I have a very large number of samples so I can not juge the plot? – baddy Feb 19 at 20:48
• There are some statistical tests, but I would start by just picking something that seems like a reasonable history that could effect your next time-step prediction. If you are predicting tomorrow's stock market price, you'd typically consider the previous few weeks or months. If you are predicting a stock price every minute, you might start with the last few hours. You can search for "How to choose number of lagged timesteps/lags in time series modelling". – n1k31t4 Feb 19 at 22:26
• Thank you for those idea so appreciated – baddy Feb 22 at 14:17

I would recommend working with LSTM-RNNs. They have been a very convenient technique to deal with the prediction of a feature based on time series of multiple inputs. This is because they can deal with the time-dependencies between all inputs/outputs as a blackbox, saving you from the hassle.

This tutorial is exactly what you are looking for. It provides you with the code to prototype your algorithm fast with Python / Keras and itt has worked very well for me regarding a problem very similar to yours.