我正在尝试使用h2o来训练决策树模型。我知道在h2o中不存在用于决策树的特定库。
这是我在h2o中使用GBM算法时的代码,但我可以像这样使用决策树。因为h2o中没有决策树代码。
GBMParametersV3 gbmParams = new GBMParametersV3();
gbmParams.trainingFrame = H2oApi.stringToFrameKey("train");
gbmParams.validationFrame = H2oApi.stringToFrameKey("test");
ColSpecifierV3 responseColumn = new ColSpecifierV3();
responseColumn.columnName = ATT_LABLE_IRIS;
gbmParams.responseColumn = responseColumn;
GBMV3 gbmBody = h2o.train_gbm(gbmParams);
...那么,如何在h2o中使用决策树算法呢?
发布于 2018-12-04 02:08:54
基于PUBDEV-4324 - Expose Decision Tree as a stand-alone algo in H2O最直接的方式是使用GBM:
titanic_1tree = h2o.gbm(x = predictors, y = response,
training_frame = titanicHex,
ntrees = 1, min_rows = 1, sample_rate = 1,
col_sample_rate = 1,
max_depth = 5,
seed = 1)这将在泰坦尼克型数据集(此处提供:https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv)上创建决策树最大5个拆分深度(max_depth = 5)
从版本3.22.0.1 (Xia)开始,可以从H2O模型中提取树结构:
titanicH2oTree = h2o.getModelTree(model = titanic_1tree, tree_number = 1)https://stackoverflow.com/questions/52068666
复制相似问题