Skip to main content
. 2022 Jun 30;24(7):910. doi: 10.3390/e24070910
Algorithm 2 PGraphDD-SS: concept drift detection using similarity score
  • Require: 

    Event stream: S, LSTM model: μ, Threshold: ϕ

  • 1:

    simScore[], DriftLog[]

  • 2:

    efetch(eventStream)

  • 3:

    wwinSize {the window size}

  • 4:

    partssplitLog(e,w)

  • 5:

    for alli in range(0, parts) do

  • 6:

      ji+1

  • 7:

      if i=parts1 then

  • 8:

        j0

  • 9:

        Rpart(i), Dpart(j)

  • 10:

      end if

  • 11:

      while w0 do

  • 12:

        prepare(R,D)    {compile and train two lstm model on the reference and detection window}

  • 13:

        μ1(μ,R), μ2(μ,D)

  • 14:

            {Make predictions for both}

  • 15:

        Rpredpredict(μ1,R)

  • 16:

        Dpredpredict(μ2,D)

  • 17:

            {build next event prediction probability matrices, construct graphs}

  • 18:

        PijRgenerate(Pred_Prob_Mat,Rpred)

  • 19:

        PijDgenerate(Pred_Prob_Mat,Dpred)

  • 20:

        GRdrawGraph(i,o,N,E,PijR,Rpred)

  • 21:

        GDdrawGraph(i,o,N,E,PijD,Dpred)

  • 22:

            {generate adjacency matrices, measure similarity score}

  • 23:

        AijRgenerate(adjacency_matrix,GR)

  • 24:

        AijDgenerate(adjacency_matrix,GD)

  • 25:

        pperformance()

  • 26:

        simScorep.getScore()

  • 27:

        M0 {set a counter of non-zero values}

  • 28:

        MgetM(AijR,AijD)

  • 29:

        absoluteVal(AijRAijD)

  • 30:

        sumValabsoluteVal.abs().sum().sum()

  • 31:

        simScore1sumVal/M

  • 32:

        if simScoreϕ then

  • 33:

           print(driftfoundinwindow+str(j))

  • 34:

              {change point detected and reported}

  • 35:

        end if

  • 36:

        Report(i,j,simScore)

  • 37:

    end while

  • 38:

    end for