Skip to main content
. 2023 Sep 4;23(17):7647. doi: 10.3390/s23177647
Algorithm 1 Model Training and Forecasting Evaluation
Require: fsc, frc
Ensure: Forecasting unseen stator FFT current seg_fsc,
       Forecasting unseen rotor FFT current seg_frc
  • 1:

    Data preprocessing using MinMaxScale method:

    r,s←MinMaxScale(fsc,frc)

  • 2:

    Split preprocessed data into training and testing data with a ratio of 80:20, respectively

    // For rotor data:

    r_tr,s_tr←r[:len(r)×0.8],r[len(r)×0.8:]

    // For stator data:

    r_te,s_te←s[:len(s)×0.8],s[len(s)×0.8:]

  • 3:

    Create function split_IO() to split input and output from training and testing data

    (Xr_tr,yr_tr),(Xr_te,yr_te)←split_IO(r_tr,r_te)

    (Xs_tr,ys_tr),(Xs_te,ys_te)←split_IO(s_tr,s_te)

  • 4:

    Setup several hyperparameters of Bi-LSTM model:

    ni,nh,no←numberofinput,hidden,outputnodes

    op←trainingoptimizer

    loss←traininglossfunction

    val←validatingsplitvalue

    call←EarlyStoppingfunction

  • 5:

    while i≤epochs(ep)do

  • 6:

        Create BiLSTM layer:

        BiLSTM←LSTM(ni,nh,no,nf,op,loss)

  • 7:

        Create fit() function to learn:

         f_r←BiLSTM.fit(Xr_tr,yr_tr,ep,val,bat,call)

         f_s←BiLSTM.fit(Xs_tr,ys_tr,ep,val,bat,call)

  • 8:

    end while

  • 9:

    Training evaluation

    mse_r,mse_s←f_r[loss],f_s[loss]

  • 10:

    Testing evaluation

    seg_frc←BiLSTM.prediction(Xr_te)

    seg_fsc←BiLSTM.prediction(Xs_te)

  • 11:

    Calculate RMSE and MAE losses

    error_r←seg_frc−yr_te

    error_s←seg_fsc−ys_te

    rmse_r←sqrt(mean((square(error_r))))

    rmse_s←sqrt(mean((square(error_s))))

    mae_r←mean(abs(error_r))

    mae_s←mean(abs(error_s))

  • 12:

    return seg_frc,seg_fsc