Algorithm 1 Train_test_evaluate |
Input: X_train, X_test, y_train, y_test, models Output: Score, Modelchoice Begin Writing a function to train, test, and evaluate models: Creating the dataframe and initializing variables: acc_M = 0 Modelchoice = ”” Score = DataFrame({“Classifier”: classifiers}) j = 0 For each model in the models list model = i Training Phase: Train Model (X_train, y_train) Testing Phase: predictions = model.predict (X_test) Performance Evaluation: Metrics: Accuracy, Precision, Recall, F1-score, Matthews Correlation Coefficient, Mean Squared Error: Acc, Preci, Re_Sc, F1_S,Mcc,Mse = Classification_report(y_test, predictions). Saving model performance metrics: Score[j,”Accuracy”] = Acc; Score[j,”f1_score”] = F1_S; Score[j,”recall_score”] = re_sc Score[j,”matthews_corrcoef”] = Mcc; Score[j, “precision_score”] = Preci; Score[j, “Mse_score”] = Mse Identifying the best model if acc_M < acc then acc_M = acc Modelchoice = model End j = j + 1 Endfor return Score, Modelchoice End Function |