H2O中的随机森林算法介绍及其项目实战(python实现)
包的引入:from h2o.estimators.random_forest import H2ORandomForestEstimator
H2ORandomForestEstimator 的常用方法和参数介绍:
(一)建模方法:
model =H2ORandomForestEstimator(ntrees=n,max_depth =m)
model.train(x=random_pv.names,y='Catrgory',training_frame=trainData)
通过trainData来构建随机森林模型,model.train中的trainData:训练集,x:预测变量名称,y:预测 响应变量的名称
(二)预测方法:
pre_tag=H2ORandomForestEstimator.predict(model ,test_data) 利用训练好的模型来对测试集进行预测,其中的model:训练好的模型, test_data:测试集。
(三)算法参数说明:
(1)ntrees:构建模型时要生成的树的棵树。
(2)max_depth :每棵树的最大深度。