• Activity
  • Classifieds
    • annonces
    • Browse Ads
    • Edit Ad
    • Place Ad
    • Renew Ad
    • Reply to Ad
    • Search Ads
    • Show Ad
  • Groups
  • Home
  • Members
IT Skills You Need
No Result
View All Result
No Result
View All Result
IT Skills You Need
No Result
View All Result
Home Datascience

Azure Functions with R and plumber

admin by admin
17 December 2020
in Datascience
0 0
0
Azure Functions with R and plumber
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

Azure Functions is a cloud service that allows you to deploy “serverless” microservices that are triggered by events (timers, HTTP POST events, etc) and automatically scale to serve demand while minimizing latency. The service natively supports functions written in C#, Java, JavaScript, PowerShell, Python and TypeScript, and now supports other languages as well thanks to the launch last week of custom handlers for Azure Functions.
A new tutorial walks you through the process of creating a custom handler for a “hello world” R function. The process is fairly straightforward: use a couple of Azure CLI commands to set up a project on your local machine and create Azure resources, write a “handler” script in R to provide a Web service, and push a Docker container with the Azure Functions runtime, R engine, and packages needed to implement your Function. Then, when you want to update your Function all you need to do is push a new version of the container image with the updated R code. The video below shows a brief demo of the process in action:

The tutorial uses the httpuv package to implement a stripped-down Web server to implement the Function, but you can make things easier for yourself (at a small cost to performance) by using the plumber package. With plumber, you can easily annotate an R function you already have, and make it into a web service suitable for Azure Functions.
In this GitHub repository you’ll find code that implements an Azure Function to predict from a GLM model trained with the caret package, and also a Shiny app to consume the function. Follow the instructions in the README.md file to deploy your Function, and then launch the associated Shiny app. As you adjust the parameters on the left side of the application, the chart on the right updates in real time with an estimate of the probability that a car accident with those parameters would be fatal.

It’s important to note that the model prediction is not being generated by the Shiny app: rather, it’s being generated by an Azure Function running R in the cloud. That means you could integrate the model estimate into any application written in any language: a mobile app, or an IoT service, or anything that can call an HTTP endpoint. Furthermore, you don’t need to worry how many apps are running or how often estimates will be requested by the app: Azure Functions will automatically scale to meet the demand as needed.
Thanks to plumber, the “handler function” providing the Web service is very simple. All I needed to do was to decorate an existing function that made a prediction based on parameters with a couple of comments to make it into an HTTP POST endpoint compatible with Azure Functions.
#* Predict probability of fatality from params in body
#* @post /api/accident
function(params) {
model_path <- “.”
model <- readRDS(file.path(model_path, “model.rds”))
method <- model$method

message(paste(method, “model loaded”))

prediction <- predict(model, newdata=params, type=”prob”)[,”dead”]

return(prediction)
}

The only other trick is to create a container containing R and the packages to support plumber and your model, but if you’re familiar with Dockerfiles this should be quite straightforward.
If you’d like to try it out yourself, you’ll find complete instructions at the repository linked below.
GitHub (revodavid): Azure Functions for R with Custom Handlers

Tags: Data science
Healthcare’s Data Problem

Healthcare’s Data Problem

3 November 2021
The best project management software for small businesses in 2022

The best project management software for small businesses in 2022

19 April 2022
The Complete LSTM Tutorial With Implementation

The Complete LSTM Tutorial With Implementation

31 January 2022
Things to Consider For Selecting an Efficient GPS Tracking Software?

Things to Consider For Selecting an Efficient GPS Tracking Software?

18 November 2021
How Big Data Can Be Used To Improve Contract For Differences

How Big Data Can Be Used To Improve Contract For Differences

21 April 2022
NLP for Business in the Time of BERTera: Seven Misplaced Passions

NLP for Business in the Time of BERTera: Seven Misplaced Passions

9 November 2021
Share data securely across Regions using Amazon Redshift data sharing

Share data securely across Regions using Amazon Redshift data sharing

19 April 2022

A Comprehensive Guide on Recommendation Engines In 2022

14 January 2022

Top 5 Reasons Customers Choose Automation Anywhere

1 October 2020

Hackers Use AI to Create Terrifying Malware Targeting Sandboxes

16 March 2022

Why User Story Mapping?

30 July 2020

Retraining: Why You Should Have Started Yesterday

6 August 2021

Survey 2022: Would you recommend SAFe ®?

13 December 2021

Trends in AI and ML Healthcare Markets

14 December 2021

Stratus Fault Tolerant Solutions (P88)

26 January 2022

Easily send OpenPhone SMS messages from form submissions

30 March 2022

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Check our landing page for details.

Categories

  • Agile
  • AI
  • AIOps
  • AIOps & Machine Learning
  • Artificial Intelligence
  • Automation
  • Big-Data
  • Business of DevOps
  • Datascience
  • DevOps
  • IT infrastructure monitoring
  • ITIL
  • Monitoring
  • Network monitoring
  • Non classé

Recent News

New SIEMENS Products From This Week’s Virtual Tour

New SIEMENS Products From This Week’s Virtual Tour

20 May 2022
The DataHour: Create Effective DS Notebooks and Communication

The DataHour: Create Effective DS Notebooks and Communication

20 May 2022
  • Activity
  • Classifieds
  • Groups
  • Home
  • Members

© 2022 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Activity
  • Classifieds
    • annonces
    • Browse Ads
    • Edit Ad
    • Place Ad
    • Renew Ad
    • Reply to Ad
    • Search Ads
    • Show Ad
  • Groups
  • Home
  • Members

© 2022 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist