Home > database >  Accuracy, recall and precision keep changing when running the code
Accuracy, recall and precision keep changing when running the code

Time:08-17

I am comparing 4 algorithms (Logistic regression, random forest, xgboost and catboost), and I am choosing the best one based on recall.

My main problem is that everytime I am running the models, I am getting a different result for accuracy, recall, precision and F1 score. How to fix this? I have tried putting random_state=42 but I don't know if I placed it well.

Also, could someone check my code and tell me if they think it's ok? This is the link: enter image description here

CodePudding user response:

Use :

  1. import random
  2. random.seed(42)
  • Related