[Python] How to set a fixed random state in RandomizedSearchCV?

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using RandomizedSearchCV with RandomForestClassifier in scikit-learn. I want to make sure my results are reproducible across runs. Where should I set the random_state—in the classifier, in RandomizedSearchCV, or both?

    Example code:

    from sklearn.ensemble import RandomForestClassifier
    from sklearn.model_selection import RandomizedSearchCV

    clf = RandomForestClassifier()
    search = RandomizedSearchCV(clf, param_distributions=params, n_iter=10)


    What's the best practice to ensure consistent results?

    Continue reading...

Compartilhe esta Página