
Perhaps you have ever met an ATM in the "Out of service" mode.
One of the possible reasons for this condition is the lack of
electricity money in the cassettes.
')
To avoid this, it is interesting for banks to know the future - how much cash will be withdrawn from ATMs and when the money runs out completely.
Under the cut solution of this problem using a simple neural network.
First, let's understand what a neural network is. From an amateurish point of view, a neural network can be represented as a kind of “black box”, which accepts an input and outputs a certain set of parameters. Teaching a neural network means training it on a reference set of input and output data, which is called a training set.
Consider a simple example.We will learn using the neural network to find the value of the "Exclusive" OR "function.

Here, on the left,
a and
b are input parameters, and on the right,
a⊕b is the output parameter. By training a neural network on the truth table, we can feed any combinations of zeros and ones to the network input and get the right result at the output. The attentive reader has noticed that whatever value of zeros and ones we take after the training, it will coincide with one of the training pairs. In real life, this is usually not the case.
Let's return to our ATMs.To make predictions, you first need to
come up with identifying signs on which the amount of withdrawn funds depends. This is done by analyzing statistics and applying common sense. So it was found that the amount of withdrawn money on the same days of the week is usually similar. As a result, we obtained the following neural network:

For the forecast for Monday “Week 3”, the input for the neural network is supplied with data for the two previous Mondays. This neural network is good, but is not able to predict the peaks of withdrawing cash on specific dates of the month (salary?). They are well predicted by the following neural network:

For the forecast for the 5th day of “Month 3”, data for 4, 5, 6 numbers of the two previous months are fed in (this helps to improve the forecast if the “peak” day is postponed by ± 1 day due to a weekend or holiday).
As a result, one could use the average value of the predictions of the two previous neural networks. But the best solution was to combine them into one big neuron:

In order not to
violate the corporate secret of inflating an article, some important technical details (types of neurons, types of training, data normalization, etc.) were omitted in it. But I hope that the uninitiated reader has an idea of ​​how this thing works.
Hostess noteThe implementation of the
Encog machine learning framework (available under .Net, Java and C ++) was used. It allows high-level creation of neural networks, indicating the types of neurons and their number in each layer of the network:
var network = new BasicNetwork(); network.AddLayer(new BasicLayer(null, true, 2)); network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3)); network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 1)); network.Structure.FinalizeStructure(); network.Reset();
If you do not want to understand the rather complex mathematics of neurons and teaching methods, I recommend finding a ready-made library for your language.