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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…