我有一个随机森林模型,我想在水管工API上创建一个端点,以打印出有关模型的信息。当我这样做时:
print(model_rf_under)
我得到:
Random Forest
199366 samples
30 predictor
2 classes: '0', '1'
Pre-processing: scaled (30), centered (30)
Resampling: Cross-Validated (20 fold, repeated 3 times)
Summary of sample sizes: 189398, 189397, 189398, 189398, 189397, 189397, ...
Addtional sampling using down-sampling prior to pre-processing
Resampling results across tuning parameters:
mtry Accuracy Kappa
2 0.9795702 0.13258320
16 0.9621216 0.07634040
30 0.9569368 0.06746579
Accuracy was used to select the optimal model using the largest value.
The final value used for the model was mtry = 2.
我想在名为 / model_info 的端点上输出此输出。 所以我尝试了一些方法:
library(plumber)
library(htmlwidgets)
load('modeloRF.RData')
#
#* @get /model_info
function(){
print(model_rf_under)
}
#* @html
#* @get /model_info2
function(){
print(model_rf_under)
}
#* @htmlwidgets
#* @get /model_info3
function(){
print(model_rf_under)
}
但是当我这样做时:
curl http://localhost:8000/model_info
我得到以下输出:
[[" 2","0.9795702","0.13258320"],["16","0.9621216","0.07634040"],["30","0.9569368","0.06746579"]]
我的模型的代码和.RData可以下载here。