Skip to main content
. 2019 Oct 10;19(20):4383. doi: 10.3390/s19204383
Algorithm 3. Pseudocode of GXGBoot’s steps.
1. Initialization:
2. mutation_rate = 0.1 //Mutation rate for GA
3. min_mutation_momentum = 0.0001 //Min mutation momentum
4. max_mutation_momentum = 0.1 //Max mutation momentum
5. min_population = 5 //Min population for GA
6. max_population = 10 //Max population for GA
7. num_Iterations = 10 //Number of iterations to evaluate GA
8. Input:
9. Training Set, Validation Set
10. Begin
11. num_population = random.randint (min_population, max_population); // Generate initial population for GXGBoost
12. population_GXGBoost = [[]
13. For i in range (num_population):
14. GXGBoost_parameters = random.randint (min_num_estimators, max_num_estimators) // GXGBoost parameters generation
15. GXGBoost_ model = generate_ GXGBoost (GXGBoost_parameters)
16. population_GXGBoost.append (GXGBoost_ model)
17. End for
18. max_accuracy = 0
19. best_model = None
20. population_validation_accuracy= [[]
21. For i in range (num_Iterations):
22.  For j in range (num_population):
23.  GXGBoost_model = population_GXGBoost [j] // population selection
// population evaluation
24.  validation_accuracy = evaluate_ GXGBoost (GXGBoost_model, Training_Set, Validation_Set)
25. population_validation_accuracy.append (validation_accuracy)
26. If validation_accuracy > max_accuracy:
27.  max_accuracy = validation_accuracy
28.  best_model = GXGBoost_model
29. End if
30. End for
31. // Create new population with new generations
32. # every generation will use the current best GXGBoost_model to mate
33. For pop_index in range (num_population):
34.  model1 = population_GXGBoost [pop_index]
35.  model1_validation_accuracy = population_validation_accuracy [pop_index]
36.  model2 = best_model
37.  model2_validation_accuracy= max_accuracy
38.  // Create new generation with crossover
39.  new_model = crossover_GXGBoost (model1, model1_validation_accuracy, model2,
model2_validation_accuracy)
40.  mutate_GXGBoost (new_model) // Mutate new generation
41.  population_GXGBoost [pop_index] = new_model // Replace current model
42. End for
43. End for
44. Return best_model, max_accuracy
45. End