Combining random forest models in scikit learn

后端 未结 2 1509
面向向阳花
面向向阳花 2020-12-08 11:21

I have two RandomForestClassifier models, and I would like to combine them into one meta model. They were both trained using similar, but different, data. How can I do this?

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 11:48

    In addition to @mgoldwasser solution, an alternative is to make use of warm_start when training your forest. In Scikit-Learn 0.16-dev, you can now do the following:

    # First build 100 trees on X1, y1
    clf = RandomForestClassifier(n_estimators=100, warm_start=True)
    clf.fit(X1, y1)
    
    # Build 100 additional trees on X2, y2
    clf.set_params(n_estimators=200)
    clf.fit(X2, y2)
    

提交回复
热议问题