2021年2月6日星期六

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  }   
https://stackoverflow.com/questions/66066685/how-can-i-upload-a-csv-file-to-a-plumber-api-in-r-to-get-predictions-from-a-mode February 06, 2021 at 12:11AM

没有评论:

发表评论