Dave Rendón Microsoft Azure MVP, embracing and fostering tech intensity to benefit society and thrive in a digital world.

Predict Temperature using Azure Machine Learning

2 min read

Azure Machine Learning - wikiazure

In this article I will show you how to use Azure Machine Learning  to predict temperature using Azure IoT. This article is part of the IoT Virtual Bootcamp –  Predict Temperature using Azure IoT & Raspberry Pi3.

Required Hardware:

Required Operating System:

  • Windows 10

Other Requirements:

  • Azure Subscription


Lab 6. Predict Temperature using Azure Machine Learning

  1. Go to http://portal.azure.com click the Plus sign on the left and search for Machine Learning Workspace. Name your Workspace, select the subscription, existing resource group, storage account and Web Service Plan and click create.

2. Click the Resource Group Icon on the left, select the resource group you created and click on the Workspace just created. Click the “Launch Machine Learning Studio” button.


3. At the Machine Learning Studio, click Sign In


4.  At the Studio, you may need to change your Workspace

5. At the bottom of the Studio, click New and then click Blank Experiment.


6. Now you will be in a blank experiment, as shown below.


7. Drag the Import Data item to the experiment.  Select Blob Storage and use the SAS token below.  For simplicity, click URI has header row ad use cached results.  Lastly, click run at the bottom to cache the data for the next step



8. Next, add the Split Data item, so we can train and test on the dataset.

9. Next, add a Train Model item, connect the data points and click the “launch column selector” to determine what element to predict.  Select the avg column and click the check box at the bottom.

10.  Next, add a Score Model item, and connect the Split Data and Train Model outputs to the Score Model, as shown below.

11. Next, add a “Two-Class Boosted Decision Tree” item, and connect it to the Train Model, as shown below.  Lastly, click the Run button to build and score the model.

12. Once the run is complete, right click on Score Model -> Scored Dataset -> Visualize to see the probabilities and statistics



13. Next, we will create a Predictive Web Service by clicking “Set-Up Web Service” -> Predictive Web Service

Once the Web Service is Setup, Run the web service.

14. Once the Web Service has been run, Deploy the Web Service using the [New] Option.  Note, this is not available for the Free Workspace. Name the Web Service and Select the Pricing Plan  and click Deploy.


15. Go back to the Azure Portal, and select the Stream Analytic Job.

16. Assuming the Stream Job is running, stop the Job before the next step.  Click on Functions to add a function.


17. Click on the newly created Stream Function to see what parameters it expects and returns.  Lastly, click on the Query button on the left

You can modify the code for the query:


With IoTData as (
select *, udf.PredictTemperature (
CAST(temperature as BigInt),
DATEPART(minute, System.TimeStamp) ,
DATEPART(hour, System.TimeStamp) ) as prediction
from iothub

IoTData.iothub.connectiondeviceid as deviceName,
DATEPART(minute, System.TimeStamp) as minute,
DATEPART(hour, System.TimeStamp) as hour,
DATENAME(weekday, System.TimeStamp) as day,
DATENAME(month, System.TimeStamp) as month,
DATENAME(year, System.TimeStamp) as year,
CAST(prediction.[Scored Probabilities] as float) as score
INTO powerbi
group by
TumblingWindow(minute, 1), IoTData.iothub.connectiondeviceid, prediction.[Scored Probabilities]

SELECT *, CAST(prediction.[Scored Probabilities] as float) as score INTO blob from IoTData


This completes this lab.

Dave Rendón Microsoft Azure MVP, embracing and fostering tech intensity to benefit society and thrive in a digital world.

Leave a Reply

Your email address will not be published. Required fields are marked *