cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Machine Learning
Dive into the world of machine learning on the Databricks platform. Explore discussions on algorithms, model training, deployment, and more. Connect with ML enthusiasts and experts.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Query ML Endpoint with R and Curl

BogdanV
New Contributor III

I am trying to get a prediction by querying the ML Endpoint on Azure Databricks with R. 
I'm not sure what is the format of the expected data. Is there any other problem with this code?

R Code.png

โ€ƒ

Thanks!!!

 

1 ACCEPTED SOLUTION

Accepted Solutions

BogdanV
New Contributor III

Hi Kaniz, 

I was able to find the solution. You should post this in the examples when you click "Query Endpoint"
You only have code for Browser, Curl, Python, SQL. You should add a tab for R
Here is the solution:

library(httr)
url <- "https://adb-********.azuredatabricks.net/serving-endpoints/********/invocations"
db_token="dap*******"
headers <- add_headers('Authorization'==paste('Bearer', db_token, sep=' '),
"Content-Type" = "application/json")

data='{"dataframe_split": {"columns": ["***columnName1String***", "***ColumnName2Integer****"], "data": [["val11", val12], ["val21", val22], ["val31", val32]]}}'
response= POST(url,headers,body=data)
results <- content(response, "parsed")

View solution in original post

1 REPLY 1

BogdanV
New Contributor III

Hi Kaniz, 

I was able to find the solution. You should post this in the examples when you click "Query Endpoint"
You only have code for Browser, Curl, Python, SQL. You should add a tab for R
Here is the solution:

library(httr)
url <- "https://adb-********.azuredatabricks.net/serving-endpoints/********/invocations"
db_token="dap*******"
headers <- add_headers('Authorization'==paste('Bearer', db_token, sep=' '),
"Content-Type" = "application/json")

data='{"dataframe_split": {"columns": ["***columnName1String***", "***ColumnName2Integer****"], "data": [["val11", val12], ["val21", val22], ["val31", val32]]}}'
response= POST(url,headers,body=data)
results <- content(response, "parsed")

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now