![fabd78966c4947e588a28c979f9c5391.jpg](https://habrastorage.org/r/w780/files/fab/d78/966/fabd78966c4947e588a28c979f9c5391.jpg)
Perhaps you have ever encountered an ATM in the “Out of service” mode.
One of the possible reasons for this condition is the lack
To prevent this from happening, banks are interested in knowing the future - how much cash will be withdrawn from ATMs and when the money will completely run out.
Below is the solution to this problem using a simple neural network.
First, let's figure out what a neural network is. From an amateur’s point of view, a neural network can be imagined as a kind of “black box” that takes as input and produces a certain set of parameters as output. To train a neural network means to train it on a reference set of input and output data, which is called the training set.
Let's look at a simple example.
Let's learn how to use a neural network to find the value of the "Exclusive OR" function.
![595ff83cf2d34ef28ea19c10ff47c5af.png](https://habrastorage.org/r/w1560/files/595/ff8/3cf/595ff83cf2d34ef28ea19c10ff47c5af.png)
Here, on the left, a and b are the input parameters, and on the right, a⊕b is the output parameter. Having trained a neural network on a truth table, we can feed any combination of zeros and ones to the network input and get the correct result at the output. An attentive reader noticed that no matter what value of zeros and ones we take after training, it will coincide with one of the training pairs. In real problems this is usually not the case.
Let's return to our ATMs.
To make predictions, you first need
To forecast for Monday of “Week 3”, data for the two previous Mondays is supplied to the input of the neural network. This neural network is good, but it is not able to predict the peaks of cash withdrawals on specific dates of the month (salary?).
For the forecast for the 5th day of “Month 3”, data for the 4th, 5th, 6th of the previous two months is input (this helps improve the forecast if the “peak” day is moved ±1 day due to a holiday or holiday).
The result could be the average of the predictions of the two previous neural networks.
In order not to
Note to the hostess
For implementation, the Encog machine learning framework (available for .Net, Java and C++) was used. It allows you to create neural networks at a high level, specifying the types of neurons and their number in each layer of the network:
Code:
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 don't want to understand the rather complex mathematics of neurons and learning methods, I recommend finding a ready-made library for your language.