# Linking Singular Spectrum Analysis and Machine Learning for Monthly Rainfall Forecasting
## 3 Methodologies
### Coupling SSA with Machine Learning (LS-SVR and RF)  
The values of monthly rainfall were standardized by their respective means and standard deviations prior to training the standard models (LS-SVR and RF). To train the standard models, the standardized rainfall values were then used. As mentioned in Section 3.1, two parameters, the penalty term (\(\gamma\)) and the kernel width (\(\sigma\)), should be selected in the calibration process of the LS-SVR model. The grid search technique is utilized for optimizing parameters during the calibrating period of the LS-SVR model. The grid search technique is capable of producing an optimum parameter set and can overcome the problems of over-fitting of the model by means of the cross-validation procedure.  
RF has two parameters, the number of variables \(\sqrt{M}\) (mtry) and the number of trees (ntree), which need to be determined. Ref [93] found that \(\sqrt{M}\) (mtry) would usually produce near-optimum results, so the value of mtry was selected by trial and error using the value around \(\sqrt{M}\) (value of M is 4). The range of ntree from 0 to 2000 was used to search the best value. However, no substantial change was achieved compared to the default value for ntree of 500. Hence, the value of 500 for ntree was adopted in this current study.  
The areal monthly rainfalls in Deji Reservoir watershed from 1981-2017 and in Shihmen Reservoir watershed from 1958-2018 were used. In Deji Reservoir watershed, the first 25 years of rainfall data were applied for training and the remaining 10 years of rainfall data were used for testing, whereas in Shihmen Reservoir watershed, the first 41 years of rainfall data were used for training and the remaining 18 years of rainfall data were used for testing. The areal monthly rainfall forecasting for each reservoir watershed was implemented using the forecasting models (i.e., LS-SVR and RF). The collection of appropriate input data sets is a major concern for LS-SVR and RF modeling. Different combination of antecedent values of the rainfall data were considered as inputs (i.e., (1) R(t); (2) R(t), R(t-1); (3) R(t), R(t-1), R(t-2)). The output is rainfall times series data to be forecasted with 1-, 2-, and 3-month lead-time (i.e., R(t+1), R(t+2), and R(t+3)).  
The hybrid models (i.e., SSA-LSSVR and SSA-RF) were obtained by combining two different methods. In view of the SSA's dominance, the hybrid models are designed to improve forecasting performance and reliability. The results of the standard and hybrid models are compared to assess the model performance in rainfall forecasting in different study catchments.  
The subsequent steps give a summary of the methodological processes for the model:  
1. Initially, the time series of rainfall data was decomposed into several principal components (PCs) using SSA.
2. The relevant principal components are calculated on the basis of the trend or period of each series, and a new series for each variable is constituted by adding up the primary components to be defined. The new series was used to construct model input.
3. LS-SVR and RF models are applied to every component of the reconstruction so that the architecture of LS-SVR and RF is different for each component of the reconstruction.
4. Finally, LS-SVR and RF models are fed with the new series to forecast the future rainfalls for 1-, 2-, and 3- month lead-time. This is the principal idea of coupling SSA with machine learning techniques (LS-SVR and RF), as illustrated in Figure 2.