# Application of Machine Learning for Bulbous Bow Optimization Design and Ship Resistance Prediction
## 2 Materials and Methods
### Error-Based Ensemble Prediction Model  
Neural networks can form intricate input-output relationships via multilayer nonlinear transformations, making them appropriate for multivariate nonlinear issues regarding the impact of bulbous bows on ship resistance. Consequently, this study selected the backpropagation (BP) neural network [24] and radial basis function (RBF) neural network [25] as the foundational prediction models. The BP neural network comprises input, hidden, and output layers, with one or more hidden layers, each containing multiple nodes. The interconnections between nodes across layers are represented by weights, which enhance the nonlinear fitting and generalization capabilities. The structure is illustrated in Figure 5, and the mapping relationship is expressed as follows:  
\[y=\sigma(\,\sum\omega_{i}x_{i}+b\,) \tag{10}\]  
where \(y\) is the output value of the network, \(\sigma(\,x\,)\) is the activation function, and \(\omega\) and \(b\) are the weights and biases of the node-to-node connections. During the training process, a loss function \(L=\frac{1}{2}\sum_{i=1}^{n}(y_{i}-\hat{y}_{i})^{2}\) is formed based on the difference between the output and the expectation. The weights and thresholds are adjusted using the gradient descent method to minimize the loss function. In contrast to BP networks, the hidden layer of an RBF network consists of a set of radial basis functions with different parameters. The radial basis functions take values dependent on a real-valued function of the distance from the origin: \(\varphi(\,x\,)=\varphi(\,\left\|x\right\|\,)\), or the distance to any specified point: \(\varphi(\,x\,)=\varphi(\,\left\|x-c\right\|\,)\). The hidden layer converts input vectors from a low-dimensional space to a high-dimensional hidden space, transforming a previously nonlinear and inseparable scenario into a linear problem, thereby enhancing the learning speed and mitigating the local minimum issue. The mapping relationship of the hidden layer \(\varphi\) in an RBF network using a Gaussian kernel function as the basis function is defined as follows:  
\[\varphi_{i}(x)=exp(-\frac{1}{2\sigma_{i}^{2}}(\left\|x-d_{i}\right\|)^{2}),i=1,2,\ldots k \tag{11}\]  
where \(\sigma_{i}\) is the width of the \(i\)th Gaussian kernel function, \(d_{i}\) is the center of the \(i\)th Gaussian kernel function, and \(\sigma=\frac{c_{max}}{\sqrt{2}k}\), where \(c_{max}\) is the maximum Euclidean distance between all centers. The accuracy of surrogate models, as an efficient prediction method for approximating the CFD simulation results, is usually obtained based on the sum of the error averages of  
Figure 5: BP neural network structure diagram. the dataset, which is a metric given from the whole. For localized samples in the dataset, the accuracy of one model may not be better than the other, even if there is a significant difference in their error averages. Taking the BP and RBF models as examples, Table 3 lists some of the ship resistance results obtained for a particular training as well as the actual sample values. The calculations show that for the five sample points, the mean error of the BP model is 1.1124 and that of the RBF model is 0.7861. From the data in the table, it can be seen that although the mean error of the RBF model is smaller, the BP prediction is more accurate for the first two sample points. This phenomenon demonstrates the limitation of the accuracy of using a single surrogate model. Therefore, this paper proposes a surrogate model based on convolutional neural networks that integrates BP and RBF models, called the CBR agent model. The model can be divided into three modules with the structure shown in Figure 6. The prediction module uses different single surrogate models--the BP neural network and RBF neural network--to train the original samples and input the prediction error of each sample point into the decision module. The decision module uses a convolutional neural network (CNN) [26] to train the original sample inputs along with the acquired errors.