H2O randomForest中的多类分类

问题描述 投票:0回答:1

我正在尝试使用H20 randomForest在R中进行多类分类,但是当我运行代码时,randomForest总是作为回归模型出现-尽管目标变量是一个因素。我正在尝试预测“梯度”(一个具有5个级别的因子),另一个因素“周期”(具有4个级别)和21个数字预测因子。

任何帮助将不胜感激。下面的代码。...

>str(df)

Class 'H2OFrame' <environment: 0x000001f6b361abe0>

 - attr(*, "op")= chr ":="
 - attr(*, "eval")= logi TRUE
 - attr(*, "id")= chr "RTMP_sid_aecc_35"
 - attr(*, "nrow")= int 63878
 - attr(*, "ncol")= int 22
 - attr(*, "types")=List of 22
 - attr(*, "data")='data.frame':    10 obs. of  22 variables:

  ..$ Gradient: Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1

  ..$ Period  : Factor w/ 4 levels "Dawn","Day","Dusk",..: 2 2 2 2 2 2 2 2 2 2

  ..$ AC1     : num  1792 1793 1790 1790 1797 ...
  ..$ AC2     : num  316 316 318 317 324 ...
  ..$ AC3     : num  972 972 974 975 979 ...

剩余的数字预测变量等。

>train <- h2o.assign(splits[[1]], "train.hex")  
>valid <- h2o.assign(splits[[2]], "valid.hex")   
>test <- h2o.assign(splits[[3]], "test.hex")     
rf1 <- h2o.randomForest(         
  training_frame = train,        
  validation_frame = valid,      
  x=2:22,                        
  y=1,                          
  ntrees = 200,                 
  stopping_rounds = 2,          
  score_each_iteration = T,     
  seed = 1000000) `
>perf <- h2o.performance(rf1, valid)
>h2o.mcc(perf)
Error in h2o.metric(object, thresholds, "absolute_mcc") : 
      No absolute_mcc for H2OMultinomialMetrics
r random-forest h2o
1个回答
0
投票

这应该使工作完成。

h2o.randomForest(...,分类= TRUE)

https://www.rdocumentation.org/packages/h2o/versions/2.4.3.11/topics/h2o.randomForest

© www.soinside.com 2019 - 2024. All rights reserved.