Skip to main content
. 2022 Mar 4;22(5):2018. doi: 10.3390/s22052018
Algorithm 1.χ2-BidLSTM implementation process

                      ▹ Obtain the χ2 test scores for each feature using χ2 statistical model

                    ▹ Rank(sort) the features in descending order based on their χ2 test scores

  • 1:

    arr← {}

  • 2:

    for i ← 1 to n do

  • 3:

        test_scorechi.sqaured(D[i],L)▹ Compute the χ2 score between features in the dataset D and class labels L

  • 4:

        append (i, test_score) toarr

  • 5:

    end for

  • 6:

    rank the features of arr▹ Sort the features in a descending order based on their χ2 test scores

  • 7:

    store the feature scores of arrtoSELECTED

  • 8:

    returnSELECTED

                   ▹ Find the features with the highest test value (v_max) from the ranked features

                           ▹ Obtain the best feature subset for training using forward search

  • 9:

    SELECTED← {}

  • 10:

    v_max←−1

  • 11:

    SubF← index of D

  • 12:

    whileSubF != NULL do

  • 13:

        indexNULL

  • 14:

        for i ← 0 toSubF length do

  • 15:

             tempfeature_list(SELECTEDSubF[i])

  • 16:

             tempvv(tempfeature_list)

  • 17:

             if tempv>v_max then

  • 18:

                index ← i

  • 19:

             end if

  • 20:

        end for

  • 21:

        if index == NULL then

  • 22:

            break

  • 23:

        else

  • 24:

            append SubF[index] to SELECTED

  • 25:

            Remove SubF[index] from SubF

  • 26:

        end if

  • 27:

    end while

  • 28:

    return SELECTED as optimal set

                   ▹ Model training interface with a K-fold cross-validation using the optimal set

  • 29:

    for f = 1 to k do

  • 30:

        [ ]Training_set = New_List[|V|]

  • 31:

        [ ]Testing_set = New_List[|V|]                        ▹ Construct the training set

  • 32:

        for m = 1 to k do

  • 33:

            if m == f then

  • 34:

               continue

  • 35:

            end if

  • 36:

            for v = 1 to |V| do

  • 37:

               Train[v] + fold[v][m]

  • 38:

            end for

  • 39:

        end for                                  ▹ Construct the testing set

  • 40:

        for v = 1 to |V| do

  • 41:

            Test[v] + fold[v][m]

  • 42:

        end for                         ▹ Fit BidLSTM model for training and testing

  • 43:

        model = BidLSTM()

  • 44:

        BidLSTM.Fit(Train)                            ▹ Train model with K-1 folds

  • 45:

        Evaluate model perfomance with remaining Kth folds

  • 46:

        scores = cross_val_scores()

  • 47:

        Return scores                  ▹ Return the classification accuracy and validation scores

  • 48:

    end for

  • 49:

    Test model with an unseen test dataset

  • 50:

    Return test scores