How to deploy an R XGboost model in UbiOps

By 25 August 2021Blog, Functionality

Imagine this, you have just created a trained machine learning model or written an algorithm in R, and now you are looking for ways to put that code into practice. Well, you have come to the right place. UbiOps is a SaaS service that lets you make your data science application a reality and supports both R and Python code. This article will show you the most important steps to deploy an R XGboost deployment using the client library.

1. Use case 

The use case that will be used for this article is as follows: because the house prices continue to rise, a model that would predict house prices may come in handy. The model is written in R and built using the R XGboost extension.

2. Script walkthrough and instructions

Below are the most important steps on how to create a deployment using the client library of UbiOps. The steps shown in this article are as follows:  (1) connect to the UbiOps environment, (2) create the R deployment, and (3) upload the deployment package to UbiOps.  If you want to see the full R script, please check out this link.

Deployment overview

The deployment is defined as follows:


Name Input Output
r-xgboost-deployment Input_data: Blob (file) Prediction: Blob (file) 
Table 1: deployment overview


The code shown below is the code required to create the deployment. 

Connect to the UbiOps environment (1)



Sys.setenv(UBIOPS_API_URL = "")

DEPLOYMENT_NAME <- "r-xgboost-deployment"

result <- service_status()

Create the deployment (2)

deployment <- list(


 description = "r-xgboost-deployment.",

 input_type = "structured",

 output_type = "structured",

  input_fields = list(

    list(name = "input_data", data_type = "blob")

 output_fields = list(

   list(name = "prediction", data_type = "blob")


 labels = list(demo = "r-xgboost-deployment")
result <- deployments_create(data = deployment)


Upload the deployment to UbiOps (3)

result <- revisions_file_upload( = DEPLOYMENT_NAME,


 file = r_xgboost_recipe_zip

) <- result$build


status <- "queued"

while(status != "success" && status != "failed") {

  result <- builds_get( = DEPLOYMENT_NAME,

   version = DEPLOYMENT_VERSION, =


  status <- result$status




result <- deployment_versions_get( = DEPLOYMENT_NAME,




After everything has finished building, requests can be made to the deployment. 

Figure 1: request result


Looks like the deployment is working perfectly!


3. Wrap up

And that is all it takes to create an R XGboost deployment on UbiOps! We hope that this helps you in your day-to-day projects. If you want to try out UbiOps, please visit , where you can make an account and start deploying your model for free. 

For any questions or suggestions please join the UbiOps community slack channel or contact our customer support.

Download the Rscript here.