如何使用 R 在 GBM 中将训练好的模型部署到 oracle 或 C++

问题描述

假设我得到模型并且结果对我有好处。 简单的公式

# train GBM model
gbm.fit.final <- gbm(
  formula = DELTDMR ~ .,distribution = "gaussian",data = ames_train,n.trees = 483,interaction.depth = 5,shrinkage = 0.1,n.minobsinnode = 5,bag.fraction = .65,train.fraction = 1,n.cores = NULL,# will use all cores by default
  verbose = FALSE
)  

#Variable importance
par(mar = c(5,8,1,1))
summary(
  gbm.fit.final,cBars = 10,method = relative.influence,# also can use permutation.test.gbm
  las = 2
)

# devtools::install_github("koalaverse/vip")
vip::vip(gbm.fit.final)
str(ames_test)


gbm.fit.final %>%
  partial(pred.var = "DELT",n.trees = gbm.fit.final$n.trees,grid.resolution = 100) %>%
  autoplot(rug = TRUE,train = ames_train) +
  scale_y_continuous(labels = scales::dollar)

# get a few observations to perform local interpretation on
local_obs <- ames_test[1:2,]

# apply LIME
explainer <- lime(ames_train,gbm.fit.final)
#explanation <- explain(local_obs,explainer,n_features = 5)
#plot_features(explanation)


# predict values for test data

pred <- predict(gbm.fit.final,CCE)

所以我认为预测对象是 gbm.fit.final 我怎样才能保存这个对象并将它部署到 oracle 而不通过 RODBC 连接到 R? 例如我通过查询获取数据,然后他们去模型对象 gbm.fit.final 然后预测 或在代码 C++ 中部署 gbm.fit.final。 是用C++语言或python或oracle保存这个对象的方法.. 如果需要数据示例

CCE=structure(list(DELT = c(10287L,9891L,9276L,10809L,10145L,9664L,10108L,10100L,9620L,10294L,9729L,9763L,9872L,10399L,10399L),DELTDMR = c(0L,0L,4L,1L,6L,8L,8L)),class = "data.frame",row.names = c(NA,-36L))

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)