Abstract:
Forecasting is the process of estimating the relevant events of the future, based on the analysis of their past and present behavior. There are various methods of forecasting such as Statistical methods, time series methods, Machine learning methods, etc. Each method has its properties, accuracies, and costs that must be considered when choosing a specific method. However, no method can be suggested as universally applicable. Although several studies developed models to predict gold price in Sri Lanka based on traditional time series modeling such Auto Regressive Integrated Moving Average (ARIMA), Vector Auto-Regressive (VAR), etc. and Feed Forward Neural Network (FFNN), no studies has been used K-Nearest Neighbors (KNN) algorithm to predict the gold prices in Sri Lanka. So, the objective of this study is forecasting gold prices in Sri Lanka using the K-Nearest Neighbors (KNN) algorithm and Artificial Neural Network (ANN) model. This study is based on the data set of daily gold prices in Sri Lanka from June 10,2014 to June 02, 2017. First 600 data points were selected for training the models and the rest were used to test the accuracy of the models, while there were 719 data points in the set. In this study, input and output for KNN and ANN approaches have been selected as consecutive past 7dyas values and next-day value of the gold price respectively. The min-max normalization process has been used to transform the data into the range [0,1] for both approaches. The Euclidean distance has been used to find the parameter “k” in KNN that refers to the nearest data points to the unknown and the “trial and error” technique is used to choose the best ANN architecture with back-propagation learning. While parameter k in KNN was selected as 3, the optimal ANN model was 7- 4 -1 architecture, i.e. the number of nodes in the input layer, hidden layer, and output layer were 7,4 and 1 respectively. The initial weight sets between (-1,1), for input and output layers were generated randomly, the learning rate of the back-propagation learning algorithm was 0.8 and the number of iterations in the training process was 6000.