# Has anyone tried predicting the middle of a timeseries as a method to formulate a strategy towards a goal?

I’ve been thinking about how to get machine learning systems to formulate plans based on a goal for quite some time. Mostly it’s been focused on having a system predicting future events and somehow using it to evaluate the future based on actions taken. This appears to be the approach of AlphaGo and many similar AI systems designed to beat games, but it’s not very suited in real word situations where there isn’t a fixed set of actions that can be evaluated.

So I’ve been thinking about ways to get around this and tonight I had an epiphany: Formulating a plan of action and predicting future events is the exact same problem, the only difference is what part of the timeseries that is masked off during training.

Let me explain my thought here. When predicting future events you have a series of events, you mask off future events and ask the system to predict these based on the previous events. Nothing new here. But if you simply shift this masking to the middle of the time series your now asking the system to predict what connects the past events to the future events. If you train a system this way you’re training it to come up with a plan of action to get to a result. After training you can specify the future point you want and give it the current point and it will try to predict how to link those two points.

The application for this would be when you have a desired end state but you don't know how to get there. As a simple example, consider a platform game where you should collect coins. You know that the end state of the game is a level without any of the coins, so you can give that state as the future point and the system should try to connect the past (or rather current) points to the specified future point. If the system has learnt to generalize well you should not have to specify everything about the end state. For a more real world example, the system could be applied to for example engineer components or even entire products based on some requirements (end states) of that product. You might specify that you want an airplane with a certain speed, load capacity and fuel efficiency and the system designs the plane for you. Granted, the later example is a bit extreme, but given the right training data and setting (some sort of CAD software) the principle is the same.

Maybe this is obvious to everyone and I’ve just missed this, but onto my question: Where can I find more information about this kind of predictor? I’ve tried searching around but I just don’t know what terms to search for. I just end up with a bunch of time-series analysis or monte carlo tree-search algorithms. If anyone could point me in the correct direction here I would be very grateful :)

Also, if anyone has a better suggestion for the title I would also be very grateful for that.

• Re "If you train a system this way you’re training it to come up with a plan of action to get to a result." I can't see that, because it looks to me you are using past and future data to interpolate values. How could the use of future data directly help with a "plan of action" (whatever that might mean)? There is a standard statistical theory for using data to guide actions having uncertain outcomes. It will be explained in any textbook on statistical inference that introduces a "loss function" as part of formulating a statistical problem.
– whuber
Mar 11, 2021 at 14:07
• The future values help to formulate a plan of action because it acts as a goal. If it learns to correctly interpolate between the future and past values (and also learns to generalize well) you can specify the future point you want and the system will try to interpolate from the past values towards the future point you specified :) Hence giving you ”a plan of action” to get there. Mar 11, 2021 at 14:47
• That would be fine if the decision maker had access to future results! But if they do, there's no difficulty in making the decision, is there?
– whuber
Mar 11, 2021 at 14:50
• You can know how you want the future to look without knowing how to get there. Take a platformer game where you should collect coins for example, you know that the end state is a world without any coins in it, but that does not mean you know how to get there. It’s actually very common to know how you want the future to be like but not know how to get there. Note, it’s a desired future, not how the future will actually be, that’s up to the agent to make happen. This is especially true if you only need to specify parts of the end state and not the state exactly. Mar 11, 2021 at 15:03
• It's hard to see where you're going with this. You don't seem to be doing anything different than a standard analysis of the data. If you think you are, then consider editing your post to include an explicit example of what you have in mind.
– whuber
Mar 11, 2021 at 15:11

Your post is confusing. In some places, it seems you are asking about predictive analytics in general. In others you sound like your describing time series cross-validation/backtesting, and yet in others like you are talking about reinforcement learning.

You did however touch on a point that is far too often overlooked by data scientists, so I will address that specific one.

Formulating a plan of action and predicting future events is the exact same problem, the only difference is what part of the timeseries that is masked off during training.

No. This is incorrect, but I have seen many data scientists, and even entire orgs make this mistake, or at least be unaware of the consequences. In fact you can tell pretty quickly the maturity of an ML tool or process by whether they take this into account or not.

Let me explain:

• Except for a few extreme cases like object detection for generic images, or very basic NLP problems, for the overwhelming majority of predictive business problems, predictions will be less than perfect. You may get 85%, 90%, maybe even 95% accuracy, but never the perfect predictive accuracy of an image recognition model trained on 10 million images.
• Since your models will be inaccurate at least some of the time, your model needs to provide not only the predictions but also the uncertainty or confidence levels of those predictions.
• The decision you will make based on that prediction will then require that you consider the uncertainty of the predictions not the precautions themselves.
• The uncertainty is a modeling output, just like the central prediction. You can consider it a second order prediction of sorts.
• How you handle the uncertainty is not, however, a second order or 3rd order prediction. It is a decision that you have to make - you decide, you can't predict the decision. You make the decision (most often using software aides, but still).

Your plan of action will take in the predictions as input, but also consider business objectives, budgets and costs, willingness to take risks, overall business strategy, etc...and then you make a decision based on all of that.

Now if we had the magical ability to generate 100% accurate predictions all the time, then yes you are correct: There is only one possible decision, since we know the future with certainty. Since that is not the case, there are multiple possible plans of action, and the uncertainty will help decide what the risk associate with each possible plan is. After which, we decide, are we willing to take more risk or less risk, and from there make a decision.

Here are a couple of concrete examples:

• I often get asked "Can we predict the best price for which to sell our products?" No you can't. You can predict how much you are likely to sell for different price points, along with the uncertainty associated with each prediction. You know that if you lower the price you will get higher demand but lower margins. If you increase the price, you will get higher margins, but you might decrease your demand by scaring away customers. Based on the confidence intervals, you know the risk associate with each decision (in this case price point). Then you decide on how much risk you are willing to take, and you either set a high price point, knowing that you might win big, but also loose big. Or you set a lower price, and you will definitely win, but never as much as if the price point were high.
• Fraud Detection: You run an E-comm web site, and you use ML to predict whether a transaction is fraudulent or not (e.g. using a stolen credit card, etc...). You will train a classification model that will give a probability that a transaction is fraud or not. Are you more willing to occasionally anger a legitimate customer by erring on the side of caution and flagging transaction that have only a 50% chance of being fraud? Or do you care more about customer satisfaction and are willing to occasionally loose money, as long you know that your legitimate customers will always be happy? In fact you probably won't use just the probability alone. You will likely also factor the sum of money involved in the transaction: For lower sums, you will be willing to let a fraudulent transaction pass, since you're better keeping your customers happy. For larger sums, you will more likely flag a 50% probability of fraud transaction as fraud, and have someone review it at least, before allow it to pass. Where do you draw the line between the two decision approaches is again a decision, not a prediction.

If you want to see a pretty good illustration of how prediction uncertainty and risk are connected, look at the Markowitz Mean-Variance model for portfolio investments.

Now there are situations where the clear boundary I described between the prediction problem and the decision problems can get blurred, like Reinforcement Learning (which you seem to be hinting at with your statement about knowing the end state but not how to get there) or Bayesian Optimization. But if you dig a little bit deeper into those approaches, you see that under the hood they still follow the predict/decide dichotomy in their own way.

For example most RL models have a purely predictive inner loop involved, which is then used to drive the decisions the RL model makes at each iterations.

On the other hand, Bayesian Optimization treats the whole thing as a pure prediction problem, but only because you have to specify upfront what are all the decision parameters you want to use and risks you are willing to take, so that they only thing model has to do is predict accordingly.