Analysis and Prediction of Foodstuffs Prices in Tasikmalaya Using ELM and LSTM

Penelitian tentang analisis dan prediksi harga bahan pangan penting dilakukan untuk memperoleh trend dan informasi yang menarik. Tulisan ini menggunakan Long Short-Term Memory (LSTM) dan Extreme Learning Machines (ELM) sebagai model peramalan harga beras, bawang putih, daging ayam, bawang merah, telur ayam, dan cabai merah di pasar tradisional Tasikmalaya. Dataset berupa time series harian yang diperoleh dari periode April 2017 - Februari 2023. Model LSTM bekerja secara akurat untuk meramalkan harga 5 bahan pangan dan memperoleh skor MAPE kurang dari 3%. ELM bekerja dengan baik untuk memprediksi harga telur ayam, beras, bawang merah, daging ayam, dan bawang putih dengan skor MAPE kurang dari 1%. Harga beras, telur ayam, bawang merah, dan cabai merah cenderung meningkat. Nilai peramalan menjadi alat yang berguna untuk memantau tren harga bahan pangan. Analisis korelasi menemukan bahwa harga cabai


Introduction
Tasikmalaya is a city in West Java, Indonesia and it lies in 7.3258023°S 108.2201805°E.The population in this city is around 723,921 in 2021 [1].Tasikmalaya has a tropical climate and two seasons: the dry season from April to September and the wet season from October to March.
Foodstuff is a raw material food before or after processing.Food is an important thing for society.Foodstuff is a raw material of food before and after processing.The essential foodstuffs may be different from one and another country.Some essential foodstuffs in Indonesia are rice, beef, chicken, egg, garlic, chili, shallot, cooking oil, and sugar.Rice is a staple food for Indonesian and most of them eat rice every day [2].Chili, shallot, and garlic are mandatory seasonings in Indonesian cuisines.Egg, chicken, and beef are popular protein sources in Indonesian society.Sugar and cooking oil are also important ingredients in their food.
The foodstuff in Indonesia possibly changing depend on some factors, i.e., religious holidays, increases in fuel price, harvest period, and season.Indonesia is a tropical country which has wet and dry seasons.The seasons affect food consumption, planting, and harvesting period.The information on regional daily foodstuff prices in the Republic of Indonesia is provided by Information Centre for National Strategic Food Price [3].As an archipelago country, foodstuffs prices in Indonesia vary in one and other places.Therefore, analyzing and predicting the foodstuff prices is necessary to be done regionally.
The analysis and monitoring of food prices is part of the Food and Agriculture Organization of the United Nations.It is beneficial as an early warning of high prices that possibly affect food security.A study that analyses foodstuffs prices found that red chili, onion, and rice have a positive influence on inflation in North Sumatra, Indonesia [4].The increasing price of fish, vegetables, and rice rises the headcount ratio [5].The Head Count Ratio (HCR) is the proportion of the population that lives under the poverty threshold.Some research analyses the food price that impact consumption [6] [7].One of the impacts of the Covid-19 outbreak is the changing of food prices [8].Research in Kenya reveals there was a granger causality between fuel prices and food prices [9].
The research goal is to evolve an application for analyzing and predicting foodstuffs prices (rice, chicken meat, chicken egg, shallot, garlic, and red chili) in Tasikmalaya, West Java, Indonesia.The application is useful for monitoring the foodstuffs trend and predicting future prices.Moreover, the result of this paper is expected to enrich research in foodstuffs prices and monitoring analysis.

Literature Review
Machine Learning methods have been implemented for forecasting time series data.Extreme Learning Machine (ELM) is an algorithm of single hidden layer feedforward neural networks (SLFNs) [10].ELM provides the best achievement with extremely fast learning speed.SLFN consists of an input layer, a hidden layer, and an output layer [11].The number of nodes in the input layer and output layer relies on certain problems.Suppose a training set  = {(  ,   )|  = ( 1 ,  2 , … ,   )  ∈   ,   = ( 1 ,  2 , … ,   )  ∈   }, where   represents input value and   is the target.The output  of ELM using  ̂ hidden neuron can be computed using equation (1), where () is the activation function in the hidden layer [12].ELM has been used to forecast stock prices [13], coffee prices [14], and electricity prices [15].
Long Short Term Memory is a development version of Recurrent Neural Network (RNN).LSTM contains an input gate and an output gate.An input gate unit is designed to protect the memory contents stored in  from disruption by irrelevant input.An output gate unit is designed which protects other units from disturbance by current irrelevant content stored in .Suppose   denotes the -th memory cell and  is weight.The output gate   and input gate   give input to   .The mathematical models of LSTM are explained by the equation (2-8) [16].The activation of   and   at time  denotes by    () and    (), respectively.Let    () be the output of   at time .LSTM works well to predict air pollutants [17] [18] [19] and stock prices [20] [21] [22].
Previous studies have been done in forecasting the prices of foodstuffs.Research implements the Fourier model with Autoregressive Integrated Moving Average (ARIMA) and linear regression to predict the price of red chili, garlic, green cayenne pepper, onion, chili, and red cayenne pepper [23].The experimental results implement multiple linear regression on ARIMA to produce an accuracy greater than 80%.A study to forecast the price of rice, cayenne pepper, and chili in DKI Jakarta has been done using Neural Network [24].It uses daily time-series data recorded from 2016 -2018.The best model Backpropagation is obtained when the learning rate is 0.1 and error-tolerant 0.01.The models produce accuracy for rice, shallot, and chili at around 91%, 88%, and 90%, respectively.
A study implemented ELM has been used to predict the price of chicken, beef, eggs, sugar, rice, shallots, cayenne peppers, garlic, red chilies, and cooking oil in East Java [25].This research uses a time series dataset from 18 July 2016 -31 May 2019 consisting of 7060 samples.The experiment scenarios run using the price of the last 3, 7, and 30 days and the number of neurons in the hidden layer as 2 -10.The lowest average MAPE score is 0.43% and it is obtained by predicting the price based on the price of the last 3 days.The experiments using different numbers of neurons obtains the lowest average MAPE score around 0.18% when the number of neurons is 7.
A model using Backpropagation has been applied to predict cooking oil, rice, shallot, garlic, cayenne pepper, red chili, beef, chicken, sugar, and egg [26].It uses monthly data on foodstuffs prices from July 2017 -May 2022.The experimental results produce average accuracy of around 96.45%.
ARIMA has been implemented to forecast the price of shallot, garlic, and chicken in Sumedang [27].This study found that ARIMA works well for forecasting the price in a short-term period of 1 -3 weeks.The evaluation models produce an average MAPE score of less than 10%.
The exponential smoothing method has been implemented for food price prediction in Java Island and it produced an error rate of less than 10% [28].Adaptive Neuro-Fuzzy Inference System (ANFIS) model to predict the rice price obtains a MAPE score of 0.7% [29].This paper implements ELM and LSTM as models for forecasting foodstuffs prices.The reason to implement those algorithms is to find the method suitable to the dataset and perform the lowest error to get accurate forecasting values.The novelty is a web-based application for forecasting foodstuffs prices in Tasikmalaya.

Research Method Figure 1. Research Workflow
The research workflow is described in Figure 1.The data are collected from https://www.bi.go.id/hargapangan/TabelHarga/PasarTradisionalDaerah.The dataset is a time-series data from 1 April 2017 -28 February 2023.The data is foodstuffs prices in Tasikmalaya traditional market, and the price is in Indonesia Rupiah (IDR).Rupiah is the currency used in Indonesia.The dataset contains 5 variables: rice, chicken, egg, shallot, garlic, and red chili.The pre-processing phase is dedicated to managing missing values.The percentage of missing values for each variable is less than 35%.Interpolation is implemented to fill up the missing values [30].After pre-processing, the dataset is then used for trend analysis and training the model for prediction.Long Short-Term Memory (LSTM) and Extreme Learning Machines (ELM) are used as models for foodstuffs price prediction.Some 80% data is applied in the training phase and 20% data is used in the testing phase.The trained models are evaluated using MAPE, MAE, MSE, and RMSE.This research develops a web-based application for analyzing and predicting five foodstuffs' prices, i.e., rice, chicken, egg, shallot, garlic, and red chili using the trained models.

Results and Analysis
This paper runs two main experiments using LSTM and ELM.MAE, MAPE, MSE, and RMSE are used to evaluate the prediction values.It runs several experimental scenarios for LSTM and ELM to observe and find the best models for forecasting which produce the smallest error.The experiments implement the LSTM library from Tensorflow.LSTM and ELM models are trained in Python.
The LSTM models use an Adam optimizer, 25 epochs, a batch size is 32, a learning rate = 0.01, and a sigmoid activation function.It runs 16 experiments using combinations of hyperparameters.Table 1 shows the best LSTM model for each foodstuff based on the evaluation metrics.The best model for forecast rice and red chili prices implements LSTM 3 layers of 64, 32, and 16 units and time step = 3. LSTM models use three layers with 32, 16, and 8 units and time step = 7 is suitable for forecasting the price of chicken meat and chicken egg.The best LSTM models for predicting garlic prices apply three layers of 32, 16, and 8 units and time step = 3.The smallest MAPE score is obtained by the LSTM model for predicting rice prices.The biggest MAPE score is produced by the LSTM model to forecast red chili.Figure 2 shows the comparisons of actual data and prediction for each foodstuff price using LSTM best models.Those models produce predicted values close to the true values.LSTM models produce MAPE scores of less than 3 %.

Figure 2. The comparison of the actual data and forecasting results using LSTM best models
The experiments using ELM implement a different number of neurons and activation functions.ELM's best models for each foodstuff price and their evaluation metrics are displayed in Table 2.The best ELM models for predicting the price of rice, chicken egg, shallot, and garlic using 20 neurons and sigmoid activation function.A model using the Relu activation function, and 20 neurons is suitable for forecasting chicken meat prices.The best ELM model for predicting the red chili price applies 5 neuron and sigmoid activation functions.A model for forecasting the price of red chili obtains a higher MAPE score.ELM models produce MAPE scores less than 1% for predicting the  According to the experimental results, LSTM models are fit to forecast the price of rice, chicken meat, chicken egg, shallot, garlic, and red chili.ELM models work well to predict the prices of foodstuffs except for red chili.The best-trained models using LSTM and ELM are then used to develop an application for forecasting the price of rice, chicken meat, chicken egg, shallot, garlic, and red chili.This application is developed using the Indonesian language.Figure 4 shows the interface of the application.The annual and monthly trend of rice prices is described in Figure 6.From 2017 -2023, the average annual rice price increases slightly.The monthly trend finds that in June-August, the price of rice is cheapest than in other months.The farmers plant the rice in the early wet season and the harvesting time is in the dry season.It is possible to affect the rice supply and price.The annual and monthly trend of chicken meat prices is illustrated in Figure 7.The lowest price happened in 2021.In 2021, the global pandemic Covid-19 hit Indonesia.It is suspected that the pandemic affects the chicken meat price.However, there is no sufficient research related to this issue.The highest price of chicken meat is in June and the lowest price is in October.The increasing trend of chicken meat prices is from March -June and November -December.The chicken meat prices decrease from July -October.The trend of shallot price is displayed in Figure 9.In general, shallot has an increasing trend.From 2017 -2023, the price difference is around IDR 10,000.In the middle of the dry season (June -July), shallot prices are at the top of the chart.From January -June, the shallot price increased, and from July -September, it decreased.Figure 11 shows the annual and monthly trend of red chili prices.In general, the price of red chili fluctuated.The red chili price has increased from 2017 -2022 and slightly decreased in early 2023.In 2022, the highest price of red chili was around two times that of the previous year.In May, the average price of red chili is at the lowest one.However, in July, red chili is at its highest price.The most expensive price of red chili is in July.
The relationships among foodstuffs prices are measured using the Pearson correlation.Table 3 shows the correlation coefficient.It highlights the correlation coefficient that is greater than |0.2|.Rice has a positive correlation with chicken eggs, and it indicates that the price of rice and chicken egg increase and decrease together.Rice price and garlic price have a negative correlation that implies when the rice price increases, the price of garlic decreases and vice versa.The chicken egg has a negative correlation with chicken meat.The price of chicken egg, shallot, and red chili has a positive correlation with each other.It finds that the moving price of chicken eggs, shallot, garlic, and red chili is in the same direction.Generally, in the dry season May -July, the price of vegetables (shallot, garlic, and red chili) is more expensive, but the price of rice is cheaper.It relates to the farming and harvesting period.Forecasting jobs is easy to evaluate their output when the ground truth exists.However, forecasting future values when the true values are not yet present is a challenging task.The main reason to apply ELM and LSTM as models for forecasting in the developed application is to compare the forecasting results when the true values are absent.The output of LSTM and ELM is useful to be comparison tools when evaluating the forecasting of future values.The results of this paper are expected to enrich the research in analyzing and forecasting the price of foodstuffs.

Conclusion
In conclusion, LSTM models work well to forecast the price of rice, chicken meat, chicken egg, shallot, garlic, and red chili and produce MAPE scores of less than 3%.ELM models perform accurately to predict the price of rice, chicken meat, chicken egg, shallot, and garlic with MAPE scores of no more than 1%.However, the ELM model is not suitable to forecast the red chili price.The annual trend from 2017 -2023 reveals that the average price of rice, chicken egg, shallot, and red chili increased.The monthly trend shows that the price of red chili, shallot, and garlic becomes more expensive in May -July.Analyzing the correlation coefficient alone cannot reveal the causal relationship among variables.It is suspected that more variables affect the foodstuffs price.Future research will analyze the causality of foodstuff prices and meteorological conditions.

Figure 3 .Figure 4 .
Figure 3.The comparison of the actual data and forecasting results using ELM best models

Figure 7 .
Figure 7.The trend of chicken meat prices from 2017 -2023 in Tasikmalaya

Figure 8 .Figure 8
Figure 8.The trend of chicken egg prices from 2017 -2023 in Tasikmalaya

Figure 9 .
Figure 9.The trend of shallot prices from 2017 -2023 in Tasikmalaya

Figure 10 .
Figure 10.The trend of garlic prices from 2017 -2023 in Tasikmalaya

Figure 11 .
Figure 11.The trend of red chili prices from 2017 -2023 in Tasikmalaya

Table 2 The evaluation metrics for ELM best model
price of rice, chicken meat, chicken egg, shallot, and garlic.However, ELM is less accurate when predicting the price of chili because it produces a MAPE score of 23.719%.