# Predicting Output Power for Nearshore Wave Energy Harvesting
## 3 Methods
### Machine Learning Algorithms  
Machine learning is a field of study that gives computers the ability to learn from data without being completely programmed [19]. In this study, we used support vector machine (SVM), random forest (RF) and artificial neural networks (ANN) to develop a prediction model for the nearshore WEC.  
SVM is designed to find a separating hyperplane that can classify the input values into several class labels with minimum classification error and maximum separation. It can be applied to regression, classification and pattern recognition problems [20]. RF is an ensemble approach that incorporates multiple decision trees to generate accurate models. In standard trees, each node is split using the best split among all variables. In RF, each node is split using the best among a subset of predictors randomly chosen at that node. This slightly counterintuitive strategy performs well compared to many other classifiers and is robust against overfitting [21]. Artificial neural networks are mathematical models whose structure and tuning procedure have some analogies with brain neural networks and their learning process. ANNs represent a nonlinear mapping between an input vector and an output vector. They consist of a system of interconnected neurons. Neurons are interconnected by weights. The output signals from each node are a function of the sum of the inputs to the node modified by a simple nonlinear transfer function called the activation function [22]. ANN has been applied to several real-world applications including power predictions. In this study, we thoroughly analyzed the performance of the three algorithms listed above regarding nearshore wave power prediction.  
In this study, we divide the data obtained from buoy into two parts, one for training and the other for testing. From the buoy, we obtained data that are segmented into several pieces as D1, D2,..., and Dn. Simultaneously, there were the corresponding average power data, which were also divided into pieces as P1, P2,..., and Pn. Using the pairs (D1, P1), (D2, P2),..., (Dm, Pm) where m < n, we trained ANN, RF and SVM. Then, the trained algorithms can predict (estimate) the output (\(\hat{\text{P}}_{\text{m}+1},\ldots,\hat{\text{P}}_{\text{n}}\)) with the input (Dm+1,..., Dn). Since we have the actual average power Pm+1,..., Pn, we can compare these actual values with the predicted values to evaluate the ML algorithms.  
In applying machine learning algorithms, there are some parameters in the algorithms that should be set by the user before the learning process begins. We call these _hyperparameters_. To obtain the optimal performance of the ML algorithm, it is necessary to find the proper hyperparameters, a process called hyperparameter tuning [23]. The task varies in accordance with the ML algorithms. We applied a tenfold cross-validated grid search on the tunable parameters of the models. First, we applied a general search with a wider range of the parameters. Then, we applied a finer grid search in the neighborhood of the first selection to find the best values for the hyperparameters.  
In this paper, SVM, RF and ANN were chosen to address the problem. For SVM, the main task was to select an appropriate kernel that fits the problem to find the optimal values for the gamma and penalty parameter [24]. The parameter gamma is the inverse of the radius of influence of samples selected by the support vectors. If gamma is too small, the model is constrained and thus might be unable to capture the complexity of the data. On the other hand, if gamma is too large, it may lead to overfitting. The penalty parameter trades off misclassification of training examples against the simplicity of the decision surface. The main parameters tuned for the RF were the number of trees, the number of features and the criterion, which is a function to measure the quality of a split [25]. Similarly, for ANN, the number of neurons, the number of layers, the size of the batch and the number of epochs were fine-tuned.