## 3 Materials and Methods
### Methods
#### 3.2.5 Proposed Hybrid Forecasting Model: Cluster-Based Genetic Algorithm (CBGA)
Traditional GA steps in the proposed model, cluster-based demand forecasting, have been restructured for optimization by adapting them to the demand forecasting structure in e-commerce. Suggested GA steps for cluster-based demand forecasting:  
Starter Population: The population size was selected between 50 and 200 by increasing the steps to 50. Solution Representation: A gene sequence was generated for each cluster. In the proposed chromosome structure in each horizon, it is decided how much the weight of each method will be. For example, considering a 5-horizon prediction, considering that there are 7 different methods for each horizon in the chromosome structure, every method has two boxes by defining the weight between 0 and 99, so every chromosome  
Figure 1: Proposed CBGA model: cluster analysis and demand forecasting with GA.  
with \(5\times 7\times 2=70\) gene lengths will be formed. If the binary variable weight (1.0) is to be used, this value will be \(5\times 7=35\). The chromosome representation is given in Figure 2. 1. Calculation of fitness: Fitness is calculated by replacing the forecast weights shown in Figure 3 in the relevant horizons and calculating the final forecast values for that horizon. As a result of this calculation, fitness can be calculated by taking into account the MSE, MAPE, and MAE values. The MSE value was preferred in the study for testing. 2. Parent selection: The roulette wheel method is preferred. According to this method, the chance of selection of each chromosome in the chromosome pool is shared in proportion to its fitness value. With the randomly generated decimal value between 0 and 1, it is decided which chromosomes will be the parent chromosomes. 3. Crossover: Single-point crossover is used as the crossover method. However, as the number of horizons increases, the number of genes will also increase. Therefore, it will not be possible to reach good solutions in the solution space, or it will be necessary to make a large number of iterations. For this reason, crossover was applied by considering the matrix structure. In this context, as seen in Figure 4, first a random point is selected, the chromosome is divided into two separate matrices by going down the matrix columns, and then a new individual is formed with a piece from the mother and father. The steady-state crossover method was chosen. That is, the crossover is performed at each iteration. 4. Mutation: According to the model, whether or not each gene mutates is carried out by considering the mutation rate. For the mutation rate, 10% was chosen for the lower limit, and the upper limit was increased by 10 steps up to 100%. 5. Generation changes and grid search: After the child chromosomes are produced, they are added to the place of the two worst individuals in the chromosome pool. Another issue in GA is parameter selection. For this, a grid search application was made for which the most suitable setting parameters were determined. Figure 3: Crossover operation. Figure 2: Solution representation—structure of the chromosome.