Research Article

Optimization of Tree-Based Machine Learning Models to Predict the Length of Hospital Stay Using Genetic Algorithm

Table 6

Mechanism of tree-based HPO with GA.

Input: Number of folds for cross-validationK, dataset D, number of generations , population size , crossover probability CP, and mutation probability MP
Output: the optimum value of tree-based models hyperparameter
 = 0
Initialize population randomly of size
While  < G do:
 =  + 1
For p = 1 to do:
  Use the GA solutions for tree-based hyperparameters from the pth individual
  For k = 1 to K do:
   Divide D into K parts, 1 part as the testing set Test-S and () parts as the
   training set Train-S
   Train the tree-based model on the training set Train-S
   Predict the test set Test-S using the trained tree-based model
   Calculate the mean square errors (MSEs)
  End for
  Calculate the value of the fitness function based on calculated MSEs
End for
 Select 2 individuals by the steady-state selection method
 Use the uniform crossover operator with the probability CP on selected individuals
 Use the mutation operator with the probability MP on a new individual
 Add the new individual to the population
End while
Return the optimum hyperparameter values of tree-based models