Skip to content

Commit 00f28d8

Browse files
authored
Merge pull request #103724 from JimacoMS3/fix-gh-7851-weather-ml-topic
fixes for gh issue 7851 -- addresses bad data in temp and humidity co…
2 parents d507771 + 0886f43 commit 00f28d8

16 files changed

+66
-13
lines changed

articles/iot-hub/iot-hub-weather-forecast-machine-learning.md

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: iot-hub
88
services: iot-hub
99
ms.topic: conceptual
1010
ms.tgt_pltfrm: arduino
11-
ms.date: 04/11/2018
11+
ms.date: 02/10/2020
1212
ms.author: robinsh
1313
---
1414

@@ -44,24 +44,77 @@ You learn how to use Azure Machine Learning to do weather forecast (chance of ra
4444

4545
## Deploy the weather prediction model as a web service
4646

47+
In this section you get the weather prediction model from the Azure AI Library. Then you add an R-script module to the model to clean the temperature and humidity data. Lastly, you deploy the model as a predictive web service.
48+
49+
### Get the weather prediction model
50+
51+
In this section you get the weather prediction model from the Azure AI Gallery and open it in Azure Machine Learning Studio (classic).
52+
4753
1. Go to the [weather prediction model page](https://gallery.cortanaintelligence.com/Experiment/Weather-prediction-model-1).
48-
1. Click **Open in Studio** in Microsoft Azure Machine Learning Studio (classic).
49-
![Open the weather prediction model page in Cortana Intelligence Gallery](media/iot-hub-weather-forecast-machine-learning/2_weather-prediction-model-in-cortana-intelligence-gallery.png)
50-
1. Click **Run** to validate the steps in the model. This step might take 2 minutes to complete.
51-
![Open the weather prediction model in Azure Machine Learning Studio (classic)](media/iot-hub-weather-forecast-machine-learning/3_open-weather-prediction-model-in-azure-machine-learning-studio.png)
52-
1. Click **SET UP WEB SERVICE** > **Predictive Web Service**.
53-
![Deploy the weather prediction model in Azure Machine Learning Studio (classic)](media/iot-hub-weather-forecast-machine-learning/4-deploy-weather-prediction-model-in-azure-machine-learning-studio.png)
54-
1. In the diagram, drag the **Web service input** module somewhere near the **Score Model** module.
55-
1. Connect the **Web service input** module to the **Score Model** module.
54+
55+
![Open the weather prediction model page in Azure AI Gallery](media/iot-hub-weather-forecast-machine-learning/weather-prediction-model-in-azure-ai-gallery.png)
56+
57+
1. Click **Open in Studio (classic)** to open the model in Microsoft Azure Machine Learning Studio (classic).
58+
59+
![Open the weather prediction model in Azure Machine Learning Studio (classic)](media/iot-hub-weather-forecast-machine-learning/open-ml-studio.png)
60+
61+
### Add an R-script module to clean temperature and humidity data
62+
63+
For the model to behave correctly, the temperature and humidity data must be convertible to numeric data. In this section, you add an R-script module to the weather prediction model that removes any rows that have data values for temperature or humidity that cannot be converted to numeric values.
64+
65+
1. On the left-side of the Azure Machine Learning Studio window, click the arrow to expand the tools panel. Enter "Execute" into the search box. Select the **Execute R Script** module.
66+
67+
![Select Execute R Script module](media/iot-hub-weather-forecast-machine-learning/select-r-script-module.png)
68+
69+
1. Drag the **Execute R Script** module near the **Clean Missing Data** module and the existing **Execute R Script** module on the diagram. Delete the connection between the **Clean Missing Data** and the **Execute R Script** modules and then connect the inputs and outputs of the new module as shown.
70+
71+
![Add Execute R Script module](media/iot-hub-weather-forecast-machine-learning/add-r-script-module.png)
72+
73+
1. Select the new **Execute R Script** module to open its properties window. Copy and paste the following code into the **R Script** box.
74+
75+
```r
76+
# Map 1-based optional input ports to variables
77+
data <- maml.mapInputPort(1) # class: data.frame
78+
79+
data$temperature <- as.numeric(as.character(data$temperature))
80+
data$humidity <- as.numeric(as.character(data$humidity))
81+
82+
completedata <- data[complete.cases(data), ]
83+
84+
maml.mapOutputPort('completedata')
85+
86+
```
87+
88+
When you're finished, the properties window should look similar to the following:
89+
90+
![Add code to Execute R Script module](media/iot-hub-weather-forecast-machine-learning/add-code-to-module.png)
91+
92+
### Deploy predictive web service
93+
94+
In this section, you validate the model, set up a predictive web service based on the model, and then deploy the web service.
95+
96+
1. Click **Run** to validate the steps in the model. This step might take a few minutes to complete.
97+
98+
![Run the experiment to validate the steps](media/iot-hub-weather-forecast-machine-learning/run-experiment.png)
99+
100+
1. Click **SET UP WEB SERVICE** > **Predictive Web Service**. The predictive experiment diagram opens.
101+
102+
![Deploy the weather prediction model in Azure Machine Learning Studio (classic)](media/iot-hub-weather-forecast-machine-learning/predictive-experiment.png)
103+
104+
1. In the predictive experiment diagram, delete the connection between the **Web service input** module and the **Weather Dataset** at the top. Then drag the **Web service input** module somewhere near the **Score Model** module and connect it as shown:
105+
56106
![Connect two modules in Azure Machine Learning Studio (classic)](media/iot-hub-weather-forecast-machine-learning/13_connect-modules-azure-machine-learning-studio.png)
107+
57108
1. Click **RUN** to validate the steps in the model.
109+
58110
1. Click **DEPLOY WEB SERVICE** to deploy the model as a web service.
111+
59112
1. On the dashboard of the model, download the **Excel 2010 or earlier workbook** for **REQUEST/RESPONSE**.
60113

61114
> [!Note]
62-
> Ensure that you download the **Excel 2010 or earlier workbook** even if you are running a later version of Excel on your computer.
115+
> Make sure that you download the **Excel 2010 or earlier workbook** even if you are running a later version of Excel on your computer.
63116
64-
![Download the Excel for the REQUEST RESPONSE endpoint](media/iot-hub-weather-forecast-machine-learning/5_download-endpoint-app-excel-for-request-response.png)
117+
![Download the Excel for the REQUEST RESPONSE endpoint](media/iot-hub-weather-forecast-machine-learning/download-workbook.png)
65118

66119
1. Open the Excel workbook, make a note of the **WEB SERVICE URL** and **ACCESS KEY**.
67120

@@ -175,9 +228,9 @@ Run the client application to start collecting and sending temperature and humid
175228
1. Sign in to your Azure account.
176229
1. Select your subscription.
177230
1. Click your subscription > **Storage Accounts** > your storage account > **Blob Containers** > your container.
178-
1. Open a .csv file to see the result. The last column records the chance of rain.
231+
1. Download a .csv file to see the result. The last column records the chance of rain.
179232

180-
![Get weather forecast result with Azure Machine Learning](media/iot-hub-weather-forecast-machine-learning/12_get-weather-forecast-result-azure-machine-learning.png)
233+
![Get weather forecast result with Azure Machine Learning](media/iot-hub-weather-forecast-machine-learning/weather-forecast-result.png)
181234

182235
## Summary
183236

Loading
31.1 KB
Loading
27.8 KB
Loading
67.4 KB
Loading

0 commit comments

Comments
 (0)