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,sMinMaxScale(fsc,frc)

  • 2:

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

    // For rotor data:

    r_tr,s_trr[:len(r)×0.8],r[len(r)×0.8:]

    // For stator data:

    r_te,s_tes[: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,nonumberofinput,hidden,outputnodes

    optrainingoptimizer

    losstraininglossfunction

    valvalidatingsplitvalue

    callEarlyStoppingfunction

  • 5:

    while iepochs(ep)do

  • 6:

        Create BiLSTM layer:

        BiLSTMLSTM(ni,nh,no,nf,op,loss)

  • 7:

        Create fit() function to learn:

         f_rBiLSTM.fit(Xr_tr,yr_tr,ep,val,bat,call)

         f_sBiLSTM.fit(Xs_tr,ys_tr,ep,val,bat,call)

  • 8:

    end while

  • 9:

    Training evaluation

    mse_r,mse_sf_r[loss],f_s[loss]

  • 10:

    Testing evaluation

    seg_frcBiLSTM.prediction(Xr_te)

    seg_fscBiLSTM.prediction(Xs_te)

  • 11:

    Calculate RMSE and MAE losses

    error_rseg_frcyr_te

    error_sseg_fscys_te

    rmse_rsqrt(mean((square(error_r))))

    rmse_ssqrt(mean((square(error_s))))

    mae_rmean(abs(error_r))

    mae_smean(abs(error_s))

  • 12:

    return seg_frc,seg_fsc