Invoking an Automated Azure Machine Learning Model in Power BI

With Automated Machine Learning in Azure Machine Learning Service, everybody can create Machine Learning Models. No need to have an extensive understanding of Machine Learning, nor to write code. Through the user interface in the Machine Learning studio, you just provide your data, indicate the label (the thing you want to predict), specify what type of problem you want to solve (classification, regression or forecasting), and let the magic happen! Azure Machine Learning will loop through a number of algorithms and parameters, and returns you the models, and information regarding their performance. You evaluate the models, pick the best one, and deploy it as a web service with just one click.

Automated Machine Learning Diagram

Once you have your machine learning model deployed as a web service, you probably want to use it to make predictions for new data. In other words, you want to consume the webservice. There are a couple of ways how to do that. You could for example call the webservice from Python, C# or Java. But what if you are not a programmer, I mean, that's probably why you used the GUI to easily create a machine learning model in the first place!

Power BI to the rescue!

Apart from using these programing languages to call the webservice, you can invoke your model in Power BI. All you need to do is connect to the data for which you want to make predictions in Power Query, connect to Azure Machine Learning, invoke your model, and you get your predictions! It's as easy as that :-)

Let's do it!

Let me walk you through an example. Suppose that I want to predict the price of a house, using certain characteristics of that house. I have a data set with a number of houses, which includes their characteristics (e.g., their location, the distance to the nearest metro station, house age,...) and their price.

I used Automated Machine Learning to create a model based on this data. This means that I simply provided my data, indicated that I wanted to solve a regression problem, and that I was interested in predicting the house price. I waited until the Automated Machine Learning Algorithm did its magic, and subsequently, I deployed the best model as a webservice.


Say that, in the mean time, I have collected some new data with information about a number of houses in the neighbourhood. I just don't know their prices... So obviously I want to predict those using my webservice.

Let's try using Power BI! I connect to the data in Power BI Desktop. From the home ribbon, I click Azure Machine Learning, and provide my credentials.

Azure Machine Learning

In the pop-up window, all the Azure ML models to which I have access are listed as Power Query functions. The input parameters for the Azure ML model are automatically added as parameters to the Power Query function. After selecting the function that belongs to my webservice, I map the columns of my data set to the parameters of the function.

Parameter mapping

Once I hit OK, the predictions for each row of my dataset are stored in a new column.


By the way, the Power Query function is also stored as a seperate query. You can invoke it like any other Power Query function by providing values for the parameters.

Now that I have my predictions, I can close and apply, and visualize them using all my favorite Power Bi tools!

Visualize the predictions

That was easy, wasn't it? Now everybody can not only create and deploy machine learning models, but also use them to make predictions for new data :-)