Hi Scikit fans,
I want to combine multiple forests with same no. of samples but different
no. of features.
For e.g. Here are two estimators of random forest with different no. of
features:
estimator =
RandomForestClassifier(n_estimators=best_n_estimators,max_depth=best_max_depth,random_state=0)
estimator2 =
RandomForestClassifier(n_estimators=best_n_estimators2,max_depth=best_max_depth2,random_state=0)
"estimator" with 8 features and "estimator2" with 3 features.
Following the link
http://stackoverflow.com/questions/28489667/combining-random-forest-models-in-scikit-learn,
I tried to combine them as:
rfs =list()
rfs.append(estimator) # first model
rfs.append(estimator2) # second model
rf_combined_estimator = reduce(combine_rfs, rfs)
#I want to know the no. of features in the resultant model
print rf_combined_estimator.feature_importances_
I got following error:
File "/users/so/sjhanwar/ML_tool/bin/Combine_RFs.py", line 193, in main
print rf_combined_estimator.feature_importances_
File
"/software/so/el6.3/PythonPackages-2.7.6/lib/python2.7/site-packages/sklearn/ensemble/forest.py",
line 316, in feature_importances_
for tree in self.estimators_) / self.n_estimators
ValueError: operands could not be broadcast together with shapes (8) (3)
Could you please suggest how can I combine forests trained on different
datasets?
Many thanks!
Shalu
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general