Skip to main content
. 2022 Sep 21;22(19):7162. doi: 10.3390/s22197162
Algorithm 2: Fraud detection through XGboost
  • 1:

    Inputs:  Balanced Dataset S

  • 2:

    Outputs:  Transactions in Blockchain B

  • 3:

    Initialization of Dataset

  • 4:

    Spliting of S into training and testing

  • 5:

    Xtrain← input variables from dataset

  • 6:

    Ytrain← target variables to dataset

  • 7:

    Xtest← input variables from test dataset

  • 8:

    Ytest← target variables from test dataset

  • 9:

    Model = XGBClassifier  (nestimators=100)

  • 10:

    Model = Model.fit(Xtrain, Xtrain)

  • 11:

    Ypred = Model.predict (Xtest)

  • 12:

    Predictions = [round(value) for value in Ypred]

  • 13:

    if Predictions==0 then

  • 14:

    transaction=legitimate

  • 15:

    B.add (transaction)

  • 16:

    else if Predictions==1 then

  • 17:

       transaction=malicious

  • 18:

    end if

  • 19:

    return  B

  • 20:

    End