[Python] XGBClassifier different performance on different OS

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    XGBClassifier(
    tree_method='hist',
    objective='multi:softprob',
    num_class=3,
    n_estimators=50,
    max_depth=5,
    learning_rate=0.1,
    eval_metric='mlogloss',
    subsample=1.0,
    colsample_bytree=1.0,
    random_state=42,
    n_jobs=1,
    device='cpu'
    )


    This is my XGBoost classifier model. I am running same script for training the model on Windows machine and Linux machine. But the trained models are having different boosters/tree structures.

    I have verified that the data being used for training is same (using pd.testing.assert_frame_equal).
    I have verified that xgboost==2.1.1 and scikit-learn==1.5.1 are same on both the OS.
    I have used fixed random_state, and ensured that all the parameters used for the xgboost classifier are same on both OS using- assert model1.get_params() == model2.get_params().
    But the trained models (saved with .json) when compared using-
    assert model1.get_booster().get_dump() == model2.get_booster().get_dump(), gives error (comparison results into False), meaning that the booster/tree structure is different in both models.
    Since the data used for training and the model parameters are same, I expect that the resulting models should be same.

    Please guide me to have the identical models on both the systems.

    Continue reading...

Compartilhe esta Página