The method that predicts the price of foodstuffs

The concern of the citizens of countries such as Honduras, Guatemala, Nicaragua, El Salvador or Venezuela about the price of the Basic Food Basket is very high due to the influence that climatic or political factors have on it..

It is also for the non-profit organizations with which we collaborate, who wonder how to know the method that predicts the price of food and its evolution in order to be able to make decisions regarding the provision of aid to families whose economic situation makes it difficult for them to buy these basic foodstuffs.

At GIS4tech we have been working on the process of predicting the prices of the Basic Food Basket in Venezuela using as data the reports of CENDA (Documentation and Analysis Center for Workers), from the Central Bank of Venezuela and . "DolarTodaybenchmark in exchange rates.

What is the basic food basket?

The Basic Food Basket is the set of different foods expressed in quantities to satisfy the calorie needs of an average household, composed of dairy products, meats, eggs, legumes, cereals, sugars, fats, vegetables and fruit.

The method that predicts the price of foodstuffs

1. Web Scraping of Food Prices

We carry out a process of data mining of the prices of the Basic Food Basket from Venezuela's CENDA page in different formats:
Gráfica de predicción de la canasta básica alimentaria

The formats "Scraping PDF Data,andScraping HTML o Franja AnimadaThe "Canasta Básica Alimentaria" reports the prices of the Basic Food Basket in Dollars (US), but the Web reports have the prices in Bolivars, which implies that an exchange rate must be applied to make the transformation to Dollars (US), for which another Web Scraping of the page was carried out. "DolarToday"and used historical data from the Central Bank of Venezuela (BCV):

Predicción real del precio de los alimentos a 30 días usando la metodología ARIMA y google trends

2. Reconstruction and integration of data

BCV data was used to reconstruct the time series in the period where CENDA data was available prior to 2021 and DolarToday data from 2021 onwards.

With this, we were able to obtain the minimum amount of data needed to complete the dollar price data series for previous years. These are essential to create this time series and reflect the variations in food prices over time, and in turn, to predict future prices of the Basic Food Basket by applying a time series algorithm. Machine Learning TechniquesARIMA"Integrated Autoregressive Moving Average Model, which is used to find patterns to predict data:

3. Evaluation of the predictive capability of the ARIMA tool.

Before being able to directly predict the price series, training and validation data were constructed to evaluate the predictive capability of the model. The image shows the results of the algorithm training ARIMA only for 2021, which reproduces the trend:
Gráfica de predicción de datos para el método que estima el precio de los alimentos
After examining the errors and checking the predictive capacity of the algorithm, the algorithm was trained with the complete series and a 30-day prediction was made (in blue):
Gráfica de predicción de la canasta básica alimentaria

4. Prediction of the evolution of the price of the Basic Food Basket with ARIMA

The following graph shows how, thanks to the data obtained and reconstructed from 2010 to 2021, we were able to predicting future prices of the Basic Food Basket for the entire period October 2021 - October 2022:
Gráfica de predicción de la canasta básica de CENDA alimentaria

5. Prediction of the evolution of the price of the Basic Food Basket with ARIMA + Google Trends.

We incorporate to the variables already included in the algorithm ARIMA una variable externa composed of people's searches of the Basic Basket on the Internet, as reflected in Google Trends from 2010 to the date we developed this process to achieve a precise and accurate price prediction, reflected in the following image; searches are correlated with the prices of the Basic Food Basket:

Gráfica de predicción de la canasta básica de mediante búsquedas en google

Next, a new algorithm was trained incorporating the variable represented by the Google Trends keyword searches discussed above. The result shows minimum average prediction error of $4.88 (US), which indicates that the algorithm is able to reproduce price trend changes with a low margin of error:

Gráfico de errores

After this, we proceeded to the actual prediction of the prices of the Basic Food Basket for the period October 2021 - October 2022 based on the historical series and Google Trends:

Predicción real del precio de los alimentos usando la metodología ARIMA y google trends

Finally, the prices of the Basic Food Basket for the next 30 days were predicted based on the historical series and on Google Trends:

Predicción real del precio de los alimentos a 30 días usando la metodología ARIMA y google trends
Comparte en:

If you want to know more about the methodology used or how we have made it available to the public

error: Content is protected !!