Forecast of prices for horticultural products with the use of artificial neural networks

Artificial neural networks (ANN) are becoming increasingly popular, acting as a very important tool to aid in the interpretation of the market. They have been used with benefits in time series analysis, as they provide an easy mathematical treatment and faster results, facilitating decision-making. Currently in the field of business, many systems using neural networks have worked well in identifying complex patterns, learning by experience, reaching conclusions and making predictions. This article deals with the application of ANN for predicting vegetable prices due to seasonality. The networks were trained using time series data for vegetables prices from the database of the Núcleo de Estudos e Pesquisas Econômicas e Sociais (NEPES) {Center for Studies and Economic and Social Research} at Universidade Anhanguera Uniderp of Campo Grande (MS), Brazil. The results were very promising and encouraging because it was possible to forecast prices of these foods over time, serving as a good tool to help entrepreneurs in the horticultural industry. This method is very useful because it can be applied also in the retail trade and industry in helping entrepreneurs in these sectors in decision-making.


INTRODUCTION
The field of public policy on food and nutrition, and the promotion of the consumption of fruits and vegetables occupy a prominent position among the guidelines for healthy eating.The Global Strategy on Diet, Physical Activity and Health, developed by the World Health Organization (WHO) recommends the increase in consumption of fruits and vegetables among the recommendations for prevention of chronic diseases.On a national level, Brazil's Ministry of Health recommends a daily consumption of at least three servings of fruits and three servings of vegetables and legumes in its Food Guide, emphasizing the importance of varying the consumption of these foods in meals throughout the week (Figueiredo et al., 2008).
These foods are important in the composition of a healthy diet because they are sources of micronutrients, fiber and other components with functional properties.In addition, fruits and vegetables are low in energy density.*Corresponding author.E-mail: celso.correia@uniderp.edu.brAuthor(s) agree that this article remain permanently open access under the terms of the Creative Commons Attribution License 4.0 International License According to evidence presented by the World Health Report in 2003, it is estimated that up to 2.7 million lives could be saved each year worldwide, if the consumption of fruits and vegetables was adequate (Gomes, 2007).
It is evident that the consumption of fruits and vegetables should be applied in everyday life.The importance is such that a budget should be prepared taking into account the cost of these foods.Because these products are highly perishable and subject to weather and seasonal variations it is difficult to forecast long-term market prices.Thus, the introduction of a computational tool to assist in the entrepreneur's decision-making will lead to a better supply of these products, and consequently, better prices for consumers; encouraging the consumption of healthy products at a competitive cost.Therefore, the use of ANNs with its high computational power becomes a great tool capable of determining with great precision prices of fruits and vegetables over time.After training, the ANNs can provide optimal forecasts and can positively influence the stability or even the drop in prices of these products.
Artificial neural networks have been gaining more and more fans with new research, becoming a promising technology for the development of applications using artificial intelligence.The success of this tool is connected to its versatility of applications in several areas of knowledge, from the development of expert systems to the resolution of complex problems of statistical analysis.The study of ANNs seeks to develop high-performance computational algorithms based on the concepts of human intelligence, with the objective of obtaining intelligent computer systems capable of solving both simple and complex problems.The ANN, recently developed technology, has presented interesting solutions to problems in various areas such as finance, marketing, sales and purchases, as stated by Wang et al. (2013).
The pioneers in this study were the neurologist McCulloch and mathematician Walter Pitts, whom in 1943 managed to represent the first artificial neuron by copying the functional idea of biological neural network that triggers synaptic impulses when the sum of impulses from other neurons reaches its threshold shooting (synapse).The multilayer perceptron (MLP) was designed to solve more complex problems, which could not be solved by the model of a single neuron.A progressive back-propagation MLP artificial neural network was used in this study (Vieira and Roisenberg, 2010).
The ANNs apply to problems where there are experimental data or that are generated using models, of which the network adapts its weights in order to execute a given task.However, the most common way of using ANNs is learning via a set of input examples.The main tasks of the ANNs are: data classification, categorization of variables, function approximation, prediction of time, and optimization of mathematical models series (Tatibana and Kaetsu, 2010;Vieira and Roisenberg, 2010).The objective of this research was the use of ANNs in particular for the prediction of prices of fruits and vegetables over time.

LITERATURE REVIEW
Here will provide a brief study of ANNs, describing its recent history, applications in several areas of human knowledge.Angelo et al. (2011) says that an important economic activity in any society concerns marketing of goods.Retail consists of exactly the bond established between the industry and the end consumer.Forecast sales are essential so that you can manage appropriate manner the production processes and marketing.In retail this aspect is of even greater importance.Sell means to harmonize the interests of that produce with those who buy.Therefore, this work has the purpose comparatively examine the application of two retail sales forecasting methods in Brazilian market: time series and neural networks.The choice of these two techniques as the object of this comparison was raised by the importance that these two concepts have assumed in the literature.Although the use of neural networks has provided the lowest sum of squared residuals, it can be said that the results of the models employing type ARIMA themselves almost equivalent.Bressan (2004) used time-series forecasting models as a tool for buy and sell decisions of the Brazilian BM&F future contracts, in dates nearby the expiration.The models considered were ARIMA, Artificial Neural Networks and Dynamic Linear Models.The data corresponds to the weekly quotations of coffee, soybeans and live cattle prices in the spot and futures markets, between 1996 and 1999.The main objective was to calculate the medium returns of each model in buy and sell operations, in way to provide an indication of the potentials or limitations of each one, using the Sharpe Index as a comparison tool.The results indicate the financial returns were positives in most of the analyzed contracts, indicating the potential use of those models in negotiations of contracts for dates close to expiration, with prominence for operations based in the forecasts of the ARIMA and Dynamic Linear Models.Calôba et al. (2002) evaluate the complementation between forecasting techniques, in particular Neural Networks.The environment of the application is a foreign industrial sector, sales of beer in Australia.Most of the forecasting models act in a separate way, that is, treating problems through different views that exclude one another.The suggestion of this work is to use the methods in a cooperative way, looking forward to achieve better results.The article begins with some considerations on Time Series Studies, followed by a brief characterization of Neural Networks and the other methods used on this work.

Concepts of artificial neural networks (ANN)
The ANNs, theory linked to Computational Intelligence (CI) using techniques inspired by nature, searches for the development of artificial intelligent systems that mimic some aspects of human behavior, such as perception, reasoning, learning, evolution and adaptation.The main ideas regarding ANNs were presented in the work of neurologist McCulloch and mathematician Walter Pitts, whom in 1943 managed to represent the first artificial neuron by copying the functional idea of biological neural network, which triggers synaptic impulses when the sum of synaptic impulses received from other neurons reaches its excitation threshold (Kovács, 1996;Haykin, 2001).
According to Braga and Ludermir (2010), a biological neuron consists of dendrites which are designed to receive the electrical stimuli (information) transmitted by other neurons and direct them to the body of the neuron, also known as somatic body, which is responsible for collecting, combining and storing this information until an excitation threshold is reached, when an electrical discharge occurs through the axon, which consists of a tubular fiber that can reach up to a few meters and is responsible for transmitting electrical stimuli to other neurons (Figure 1).
The descriptions of the mathematical model of a biological neuron resulted in an artificial neuron model by McCulloch and Pitts (Figure 2), composed of input , with u a linear combination of these parameters obtained from the sum function of the artificial neuron, Equation (1).
The value of u increases until it reaches the excitation threshold  producing the output ) (u f y  denominated activation function (Braga and Ludermir, 2010).The parameter u is discharged, reaching values very close to zero, and the process repeats.This is also the behavior of a biological neuron, mutatis mutandis.The neuron activation function, which generates the output ) (u f y  can be represented in its simplest mode by a step function, Equation (2), which represents the approximate behavior of the biological neuron.
Several of these artificial neurons, associated in a special way, have in their functioning the representation of intelligent human behavior.Because of this, the study of ANNs is part of a special topic of the theory of Artificial Intelligence, shared with genetic algorithms, fuzzy logic, among others.
According to Haykin (2001) and Rosemblat (1950) created the first model of ANNs, which consisted of a network of multiple artificial neurons arranged in three layers, called perceptron or linear discriminator.The perceptrons are arranged in input and output layers, where the weights of the connections are adapted in order to achieve the synaptic efficiency, and can be used in character recognition; one of several applications of ANNs.
A perceptron can learn concepts through examples and respond to it when a new example is presented, with 1 if it is true, or with 0 if it is false; based on the examples given initially.An entire passage of an input vector for training is denominated time.The times are repeated until they reach a stopping criterion.If the input patterns are linearly separable, the algorithm is secured at its convergence; that is, the weights are adjusted properly in order to obtain the correct classification of the weights (Haykin, 2001).
According to Braga and Ludermir (2010), for the training, every input pattern is presented to the perceptron and its weights should be adjusted following the rule created by Rosenblatt (1958).Thus, there is i x the i-th training pattern presented to the input; .In both cases the algorithm needs to adjust the weights of the perceptron so that the output is equal to the desired output.In both cases the adjusted weights are given by Equation (3), with  as a positive climb, also known as perceptron learning rate, which indicates how much the weight vector will be modified in the direction and sense of inputs

Multilayer artificial neural networks (Multilayer perceptron -MLP)
A network with an intermediate layer can implement any continuous function.The use of two intermediate layers allows the approach of any function.The way to get perceptrons in layers is called Multilayer Perceptron (MLP).The MLP is designed to solve more complex problems, which could not be solved by the network model using only one neuron.A MLP neural network with back propagation training was used in this study (Figure 3).

Functionality
In a multilayer network, the processing performed by each neuron is defined by the combination of the processing by neurons of the previous layer that are connected to it.When there is movement from the first intermediate layer towards the output layer, the implemented functions become increasingly complex.These functions define how the division of the decision space is performed.It should be noted, however, that in some cases the use of two or more intermediate layers can facilitate the training of the network.The use of a large number of intermediate layers is not recommended.Nevertheless, each time the error measured during training is propagated to the previous layer it becomes less useful or less accurate.The only layer that has a precise notion of the error made by the network is the output layer.The last intermediate layer receives only an estimate of the error.The penultimate intermediate layer is an estimate of the estimate, and so on (Rauber, 2012).

Training MLP networks (back-propagation)
The back-propagation algorithm was a major contributor to the resurgence of interest related to ANNs.It is a supervised algorithm that uses pairs (inputs, desired output) to adjust the network weights through an error correction mechanism.Training occurs in two phases, wherein each phase directs the network in one direction.These two phases are called forward phase and backward phase.The forward phase is used to set the output network for a given pattern of inputs and at the same time updates the weights of its links.
Assuming that it is intended to train a network with an input layer, a hidden layer and an output layer, containing the latter J elements, the purpose of the training is to )) Where  is the step of training, k is the iteration number in the training process and

  w E
the square error, given by Equation ( 6).

Difficulties in training
Despite the great success of the applications of back propagation algorithm and its huge popularity, some problems still exist, such as: the long period of training especially for complex problems, where there is no guarantee that after the time spent, training will have been done successfully; local minima, since the error base is usually full of valleys and gaps and the algorithm employs a type of gradient descent, with the possibility of getting stuck in a local minimum; paralysis of the network, since during training the weights can be adjusted to very large values, which will bring the derivative of the activation function to zero (in the case of "squashing" functions), preventing the network to learn the training set.Due to the shortcomings of the back propagation algorithm, numerous variations have been proposed in recent years, although so far none has solved definitively and reliably the problems of "back propagation".

Multiple linear regression analysis
According to Brito (2012), Multiple Linear Regression statistical technique is used to study the relationship between a dependent variable and several independent variables.Generic General Linear Model is given by equation ( 7) when applied to a sample of size n.

MATERIALS AND METHODS
This research should be classified as bibliographical, as a bibliographical review of the issues surrounding the topic being studied was initially done as well as a review of these matters for setting the concepts that were used.In addition, the research should also be classified as descriptive exploratory since through fruits and vegetables price data it was sought to discover and observe phenomena, seeking to describe, sort, and interpret them.At the same time it was sought to explore in the research problem the reasons for the large seasonal and climatic changes in prices of these foods.The data used in this research was the prices of fruits and vegetables in the retail industry of Campo Grande, MS from the NEPES database; organization responsible for the monthly calculation of inflation in this city (NEPES, 2015).
In this study, the ANNs model (MLP) was used for the prediction of fruits and vegetables prices over time, and the network was trained with the learning algorithm with back propagation of errors.The MLP networks have a computational power much greater than that presented by the networks without intermediate layers.Unlike the latter, MLPs networks can deal with data that is non-linearly separable.The outputs functions of such networks need to be differentiated so that the gradient can be calculated, directing the adjustment of weights.
The objective of the training algorithm is to minimize the mean squared error (MSE) between the network output and the desired output (Rauber, 2012).The activation function used in this paper was the sigmoidal logistic function, whose orientation is determined by the direction of the weight vector The value of the bias term corresponds to the weight 0 w , which determines the location of the sigmoid function; that is, sets the position of the sigmoid function with respect to the vertical axis (Figure 4).To minimize the squared error is used the gradient 6) to correct the weights.Thus, the square error is propagated to all network layers.The correction of the weights must be repeated until you reach a square error of less than an established precision.After obtaining the optimum weights for the network, it should be tested using problems whose solutions are known, but have not been used in the network training process, and checking whether the input data to these problems, the neural network shows the expected solution.As previously mentioned, the purpose of training the network is to adjust the weights so that the application of a set of inputs can produce a set of desired outputs.Before starting the training process, all weights must be initialized randomly with small values, thereby ensuring that the network will not be saturated with large values of weights and preventing certain training conditions.Training can be divided into steps, as follows (Wang et al., 2013): (1) Select the next pair from the training set and apply the input vector to the network; (2) Calculate the network output; (3) Calculate the error between the network output and the target output; (4) Adjust the network weights to minimize the error; and (5) Repeat step 1 to step 4 for each vector in the training set, until the error becomes acceptably low for the entire set.
It may be noted that steps 1 and 2 make up the forward propagation step in which the input signal is transmitted through the network entry to the output.Steps 3 and 4, on the other hand, make up the back propagation step in which the calculated error is propagated back through the network to adjust the weights.

RESULTS AND DISCUSSION
In the network training, a MLP neural network was used to make predictions of prices of fruits and vegetables, using information from the NEPES database regarding these prices from 2009 to 2014.The series in Table 1 refers to the monthly average prices of loose-leaf lettuce in the retail market of Campo Grande, during the period of 2009 to 2014.
According to NEPES (2015), from January 2009 to December 2014 there was a cumulative inflation of 32.5% in the retail industry in the city of Campo Grande, which led to the need of updating the values since by eliminating the effect of inflation in the period it became closer to the reality of what happened in the retail market during this period, using December 31, 2014 as the basis.Table 2 presents the values in Table 1, eliminating the effects of inflation accumulated in the values of looseleaf lettuce, as well as monthly average prices of this vegetable (Gujarati, 2006).To achieve the research objective, two methods for predicting the price of this vegetable were applied to the deflated data: training an artificial neural network, and a multiple regression analysis (Hoffman and Vieira, 2006).

Training artificial neural network
It was considered as an input matrix the matrix with the monthly average values of prices of loose-leaf lettuce in retail stores in Campo Grande, Brazil, from 2009 to 2014, and as an objective, the vector formed by the monthly average of the prices of this vegetable in the mentioned  period.The MLP network was made up of 6 neurons in the input layer, 18 neurons in the hidden layer and one neuron in the output layer.The network was trained using the toolbox Matlab software, which after training presented the convergence graph of the network after 966 times with accuracy lower than 10 -5 (Figure 5).The vectors for output and error, after the trained network, are: Output_ANN = [2.46632.5722 2.7816 2.6171 2.364 2.2876 2.0861 2.2567 1.8896 2.1297 2.0877 2.2112]; Error = [0.0037472-0.0022058 -0.0016467 0.0029056 -0.004046 0.00242 0.003947 -0.0067155 0.00038908 0.00025569 0.0022615 -0.0012483].This errors are randomly distributed, so do not have normal.From this data analysis, it can be concluded that there was a great convergence.

Multiple linear regression analysis
In the multiple linear regression analysis, years were considered independent variables and the mean was considered the dependent variable.Table 3 shows the Pearson correlations between all variables.It is observed in Table 3 that there are no high correlations among the variables; therefore no multi co-linearity problem exists in obtaining the regression equation.In the variance analysis, p = 0 was obtained, indicating that the regression equation is highly significant and explained very well the studied phenomenon.According to Montgomery et al. (2001) 4 summarizes the average, output of the artificial neural networks, and the values for the multiple linear regression of the monthly average prices of loose-leaf lettuce, from 2009 to 2014. Figure 6 shows three graphs generated from Table 4, using variables AVERAGE, OUTPUT_ANN and AVERAGE_MLR.The lines of the respective graphs of the three variables overlap, indicating the excellent approximation among these three variables as well as the power of the two tools (artificial neural networks and multiple linear regression) used in the average of monthly prices of loose-leaf lettuce represented by the variable AVERAGE (Wooldridge, 2006).

Figure 3 .
Figure 3. Structure of an artificial neural network with back propagation.Source: Barber (2007).
training algorithm.Otherwise, two possibilities should be considered by the algorithm: i) backpropagation of error for the correction of the weights is defined by Equation (5).

Figure 5 .
Figure 5. Training trajectory of convergence presented by the artificial neural network of average prices of loose-leaf lettuce.

Table 1 .
Average monthly prices (in Reais) of loose-leaf lettuce in retail stores in Campo Grande, from 2009 to 2014.

Table 2 .
Average deflated monthly prices of loose-leaf lettuce in the retail industry of the city of Campo Grande, from 2009 to 2014, using December 21, 2014 as the basis.

Table 3 .
Pearson correlations between all variables for conformity by the multiple regression analysis.

Table 4 .
Values of the weighted average of the output and regression of the artificial neural networks.