多列的随机森林算法

问题描述

我想使用 Ranger 为多个物种执行随机森林。

我可以设法为每个物种分别执行此操作,但当我选择多个物种时,我收到以下错误

detection_freq <- lapply(ebird_split$train[,14:124],FUN=mean)

ebird_split$train[,14:124] <- lapply(ebird_split$train[,FUN=factor)

# grow random forest

rf <- ranger(formula =  ebird_split$train[,14:124] ~ .,data = ebird_split$train,importance = "impurity",probability = TRUE,replace = TRUE,sample.fraction = c(detection_freq,detection_freq),)

parse.formula(formula,data,env = parent.frame()) 中的错误错误:公式界面中的列名非法。修复列名或在 Ranger 中使用替代接口。 sample.fraction = c(detection_freq,)

这是一个仅使用 20 列和 15 行的可重现代码

structure(list(year = c(2014,2014,2015,2014),pland_00_water = c(0,0),pland_01_evergreen_needleleaf = c(0,pland_04_deciduous_broadleaf = c(0,pland_05_mixed_forest = c(0,pland_09_savanna = c(0.125,0.2,0.111111111111111,0.25,0.1,pland_10_grassland = c(0,0.6,pland_11_wetland = c(0,pland_12_cropland = c(0,0.333333333333333,1,0.7,0.3,0.9,0.7
),pland_13_urban = c(0.875,0.888888888888889,0.75,pland_14_mosiac = c(0,0.666666666666667,0.3),elevation_median = c(31.9876055132011,60.187326902531,63.4307961294557,55.2689008500971,53.0951598592064,22.1066004189197,24.352084994479,51.3272817386215,62.2362454373989,4.56623070514396,32.65840408727),elevation_sd = c(2.05966198806878,4.73491604153919,3.81928752524468,10.3834519297609,4.28755305909316,5.21662903838999,8.104243228417,1.76646574114901,3.11995484557375,0.12543304763668,3.89986664218466),Blackbird = structure(c(2L,2L,1L,2L),.Label = c("0","1"),class = "factor"),`Blue Tit` = structure(c(2L,Bullfinch = structure(c(1L,1L),`Carrion Crow` = structure(c(2L,Chaffinch = structure(c(2L,`Coal Tit` = structure(c(2L,`Collared Dove` = structure(c(2L,class = "factor")),row.names = c(NA,-15L),class = c("tbl_df","tbl","data.frame"))

解决方法

1L 和 2L 是什么意思?

目标特征是什么?

 year = [2014,2014,2015,2014] 
 pland_00_water = [0,0] 
 pland_01_evergreen_needleleaf = [0,0] 
 pland_04_deciduous_broadleaf = [0,0] 
 pland_05_mixed_forest = [0,0] 
 pland_09_savanna = [0.125,0.2,0.111111111111111,0.25,0.1,0] 
 pland_10_grassland = [0,0.6,0] 
 pland_11_wetland = [0,0] 
 pland_12_cropland = [0,0.333333333333333,1,0.7,0.3,0.9,0.7] 
 pland_13_urban = [0.875,0.888888888888889,0.75,0] 
 pland_14_mosiac = [0,0.666666666666667,0.3] 
 elevation_median = [31.9876055132011,60.187326902531,63.4307961294557,55.2689008500971,53.0951598592064,22.1066004189197,24.352084994479,51.3272817386215,62.2362454373989,4.56623070514396,32.65840408727] 
 elevation_sd = [2.05966198806878,4.73491604153919,3.81928752524468,10.3834519297609,4.28755305909316,5.21662903838999,8.104243228417,1.76646574114901,3.11995484557375,0.12543304763668,3.89986664218466] 
 Blackbird = ['2L','2L','1L','2L'] 
 BlueTit = ['2L','2L'] 
 Bullfinch = ['1L','1L']
 CarrionCrow = ['2L','1L'] 
 Chaffinch = ['2L','1L']
 CoalTit = ['2L','1L']
 CollaredDove = ['2L','1L']

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...