Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
388 views
in Technique[技术] by (71.8m points)

How can I upload a csv file to a plumber api in R to get predictions from a model

I have been unsuccessful in finding a way to code a plumber api in R to pass in a csv file of new data and run a saved model to obtain predictions. Any assistance would be greatly appreciated. I have added code for an API which works to input values for each feature and get the prediction I am looking for. I am lost on how to pass in more than just a single record.

load("model.rda")
library(plumber)

#* @apiTitle Prediction
#* Predict number
#* @post /predict/values
function(a, b, c, d){
  #get the df
  newdf <- as.data.frame(list(a  = as.numeric(a),
                              b  = as.numeric(b),
                              c  = as.numeric(c),
                              d  = as.numeric(d)))
  
  #get results of model
  pred <- predict(model_object,newdf)
  pred
} 
question from:https://stackoverflow.com/questions/66066685/how-can-i-upload-a-csv-file-to-a-plumber-api-in-r-to-get-predictions-from-a-mode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...