Skip to main content
. 2024 Nov 17;24(22):7336. doi: 10.3390/s24227336
Algorithm 1 The use of pseudocode in Multi-Model Federated Learning (FL) for the detection of anomalies.
  • 1:

    DLoadData()                  ▹ Load the dataset from designated directories.

  • 2:

    if any dkD is missing or invalid, apply imputation

  • 3:

    Convert D into a feature matrix: X=[x1,x2,,xn]

  • 4:

    Perform normalization on the data. X: X=normalize(X)

  • 5:

    Split X into training set Xtrain and validation set Xval

  • 6:

    clients5                                ▹ Number of clients

  • 7:

    models[OCSVM,CAE,IsolationForest,LOF,KMeans]           ▹ Array of candidate models

  • 8:

    client_datasetssplit_data_for_clients(Xtrain,clients)

  • 9:

    for each client i do

  • 10:

        for each model mmodels do

  • 11:

            Train model m on client_datasets[i]

  • 12:

            Store the trained model mi

  • 13:

        end for

  • 14:

    end for

  • 15:

    aggregated_models[]                    ▹ Array to store aggregated models

  • 16:

    for each model mmodels do

  • 17:

        Aggregate all client models for m into a global model mglobal

  • 18:

        Append mglobal to aggregated_models

  • 19:

    end for

  • 20:

    for each mglobalaggregated_models do

  • 21:

        Evaluate mglobal on Xval

  • 22:

        Calculate and present the evaluation metrics: accuracy, precision, recall, and F1-score.)

  • 23:

    end for