0
这可能是一个愚蠢的问题,但是当我在R中使用H2O Predict函数时,我想知道是否有一种方法可以指定它保留评分数据中的一列或多列。具体而言,我想保留我的唯一ID密钥。现在,我最终做了一个非常低效的方法,将原始数据集和一个索引键分配给分数,然后将分数合并到计分数据集中。我宁愿说“评分这个数据集并保留x,y,z ....列”。有什么建议?评分新数据集时保留ID密钥(或任何其他列)?
低效的代码:
#Use H2O predict function to score new data
NL2L_SCore_SetScored.hex = h2o.predict(object = best_gbm, newdata =
NL2L_SCore_Set.hex)
#Convert scores hex to data frame from H2O
NL2L_SCore_SetScored.df<-as.data.frame(NL2L_SCore_SetScored.hex)
#add index to the scores so we can merge the two datasets
NL2L_SCore_SetScored.df$ID <- seq.int(nrow(NL2L_SCore_SetScored.df))
#Convert orignal scoring set to data frame from H2O
NL2L_SCore_Set.df<-as.data.frame(NL2L_SCore_Set.hex)
#add index to original scoring data so we can merge the two datasets
NL2L_SCore_Set.df$ID <- seq.int(nrow(NL2L_SCore_Set.df))
#Then merge by newly created ID Key so I have the scores on my scoring data
#set. Ideally I wouldn't have to even create this key and could keep
#original Columns from the data set, which include the customer id key
Full_Scored_Set=inner_join(NL2L_SCore_Set.df,NL2L_SCore_Set.df, by="ID")