Classification tree in sklearn giving inconsistent answers

前端 未结 4 1224
忘了有多久
忘了有多久 2021-02-09 12:44

I am using a classification tree from sklearn and when I have the the model train twice using the same data, and predict with the same test data, I am getting diffe

4条回答
  •  眼角桃花
    2021-02-09 13:17

    The features are always randomly permuted at each split. Therefore, the best found split may vary, even with the same training data and max_features=n_features, if the improvement of the criterion is identical for several splits enumerated during the search of the best split. To obtain a deterministic behaviour during fitting, random_state has to be fixed.

    Source: http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html#sklearn.tree.DecisionTreeClassifier#Notes

提交回复
热议问题