Skip to main content
. 2024 Jun 6;24(11):3682. doi: 10.3390/s24113682
Algorithm 1 Proposed Custom Ensemble Method
  • 1:

    Input:Dr = Dataset; n_models = Number of base models;

  • 2:

    Output: Trained ensemble model merging bagging, boosting, and stacking.

  • 3:

    function Ensemble Pseudocode(Dr,n_models)

  • 4:

        Initialization:

  • 5:

        Set n_models to the desired number of base models.

  • 6:

        Initialize an empty list model_list to store the trained base models.

  • 7:

        for i=1 to n_models do

  • 8:

            Training the Base Model:

  • 9:

            Train a base model to predict class labels on the entire training dataset Dr.

  • 10:

           Append the trained model to model_list.

  • 11:

        end for

  • 12:

        Making Predictions:

  • 13:

        Initialize an empty list predictions to store predictions from each base model.

  • 14:

        for each base model in model_list do

  • 15:

            Use the base model to predict the class labels for the testing dataset.

  • 16:

            Append the predictions to predictions.

  • 17:

        end for

  • 18:

        Combining Predictions:

  • 19:

        For each instance in the testing dataset:

  • 20:

           Count the class labels predicted by each base model.

  • 21:

           Select the most frequent class label as the final prediction.

  • 22:

        Evaluating Ensemble Performance:

  • 23:

        Evaluate the ensemble’s performance on the test dataset.

  • 24:

    end function