简体   繁体   English

如何创建与R randomForest相同的sklearn随机森林模型?

[英]How to create sklearn random forest model identical to R randomForest?

In RI usually define Random Forest as follows (an example): 在RI中,通常如下定义随机森林(一个例子):

rf <- randomForest(train[,features], 
                   train$Y,
                   mtry=5,
                   ntree=15,
                   sampsize=50000,
                   do.trace=TRUE)

Now I started learning Python and I wonder how to set the same model with same tuning parameters in Python? 现在我开始学习Python,我想知道如何在Python中使用相同的调整参数设置相同的模型? I know about sklearn RandomForestClassifier , but it seems to be defined with a very different set of parameters. 我知道sklearn RandomForestClassifier ,但它似乎是用一组非常不同的参数定义的。

from sklearn.ensemble import RandomForestClassifier
#create the classifier and tune the parameters (more on the documentations)
rf = RandomForestClassifier(n_estimators= 25, max_depth= None,max_features = 0.4,random_state= 11 )
#fit the data
rf.fit(train, targets_train)
#make the prediction on the unseen data
prediction =rf.predict(test)

Have a look on that code. 看看那段代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM