我刚接触scikit-learn和随机森林回归,想知道是否有一种简单的方法可以获得随机森林中每个树的预测结果,而不仅仅是组合后的预测。
基本上,我希望能够像在R中使用predict.all = True
选项那样。
# Import the model we are using
from sklearn.ensemble import RandomForestRegressor
# Instantiate model with 1000 decision trees
rf = RandomForestRegressor(n_estimators = 1000, random_state = 1337)
# Train the model on training data
rf.fit(train_features, train_labels)
# Use the forest's predict method on the test data
predictions = rf.predict(test_features)
print(len(predictions)) #6565 which is the number of observations my test set has.
我希望获得每棵树的每个预测结果,而不仅仅是每个预测的平均值。
在Python中是否有可能实现?