(Optional) Unit 5. Building a Model in AI Hub¶
Besides building a model to predict with operators in AI Pipelines, you can also build a model in AI Hub and call model services to predict the temperature rises of wind turbine engines.This unit describes how to build a model for predicting the temperature rise of wind turbine engines in AI Hub.
Prerequisites¶
Before you start, make sure that you have finished all steps in Unit 3. Preparing Codes.
Step 1. Creating a Model¶
Log in to EnOS Management Console and select AI Studio > AI Hub from the left navigation pane.
Select New Model on the AI Hub page.
Configure the following fields in the Basics section, then select Next.
Field
Description
Name
Enter
temp-rise
.Technique
Select Classification.
Category
Select Predictor.
Input Data Type
Select Tabular.
Configure the following information in the Input/Output section.
Field
Description
API Type
Select REST.
Configuration Type
Select Customized JSON.
Enter the following script in the Input Parameter section.
{ "inputFormat": [ { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "gen_reactive_pw", "range": [], "repeat": 0 }, { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "gen_spd", "range": [], "repeat": 0 }, { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "torque", "range": [], "repeat": 0 }, { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "tem_in", "range": [], "repeat": 0 }, { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "tem_out", "range": [], "repeat": 0 }, { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "wind_speed", "range": [], "repeat": 0 }, { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "rotor_spd", "range": [], "repeat": 0 }, { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "gen_active_pw", "range": [], "repeat": 0 } ], "outputFormat": [ { "annotations": "", "defaultValue": null, "dtype": "float", "ftype": "continuous", "name": "gen_active_pw", "range": [], "repeat": 0 } ] }
Select New Version to create the model.
After the model is created, the New Version page opens. Instead of staging a new model version here, you need to go back to the temp-rise Notebook instance and build a sample file into a model image file that can be used for hosting.
Step 2. Staging a Model Version¶
Select Data Analytics > AI Studio > AI Lab on the left navigation pane.
Open the temp-rise Notebook instance you created in Unit 3. Preparing Codes.
On a terminal window, enter and run
cd_temp_rise
andpip install -r requirements.txt --user
to install dependencies.Select temp_rise > Train.ipynb to open the file.
Select the double-arrow icon on the tool bar to restart kernel and re-run the whole notebook.
After running the Train.ipynb file, select the menu icon on the lower right corner then select Go to Lab of the running record.
In the Artifacts section, select the temp_rise folder, and select New Version on the right.
In the popup window, enter
temp-rise
, the model you created, and select ToModelHub to create a new model version based on the running results of the Train.ipynb file.Select Next, the model will be built automatically.
After the model was built, select Next 2 times to go to the Deployment Test page.
Enter the following script and select Test.
{ "data": { "names": [ "gen_reactive_pw", "gen_spd", "torque", "tem_in", "tem_out", "wind_speed", "rotor_spd", "gen_active_pw" ], "ndarray": [ [ 19.646925, 963.533899, 9311.739885, 19.948558, 6.743743, 6.99086, 13.066677, 932.398765 ], [ 20.020045, 1010.172848, 10268.291071, 19.698487, 6.722673, 7.189325, 13.955926, 1070.147035 ] ] } }
Select Finish and select Confirm in the popup window to stage the model version.
After you staged the first model version, the model detail page of temp-rise opens. You can view the version you staged on the Version Management tab.
Step 3. Deploying the Model Version¶
To run a staged model version, you need to create a deployment instance to deploy the staged version to the corresponding container by the following steps:
Select Online Instance > New Instance in the detail page of the temp-rise model.
Configure the following information in the New Deployment Instance popup window.
Field
Description
Instance Name
Enter
temp-rise-instance
.Resource Pool
Select notebook.
Select Confirm and the instance appears on the instance list.
Select the instance name to open the Model Deployment page, then select Configure.
Select Add the version to be deployed, and select teh model version from the dropdown list then select OK.
Select Deploy to deploy the mode version.
(Optional) Step 4. Testing the Model Version¶
While the model version is being deployed, you can go back to the model detail page to manually test the usability of the model version by the following steps:
Select Online Instance in the detail page of the temp-rise model.
Enter the following script in the left box, then select Test.
{ "data": { "names": [ "gen_reactive_pw", "gen_spd", "torque", "tem_in", "tem_out", "wind_speed", "rotor_spd", "gen_active_pw" ], "ndarray": [ [ 19.646925, 963.533899, 9311.739885, 19.948558, 6.743743, 6.990860, 13.066677, 932.398765 ], [ 20.020045, 1010.172848, 10268.291071, 19.698487, 6.722673, 7.189325, 13.955926, 1070.147035 ] ] } }
Step 5. Calling Model Services¶
After staging a model version, call model services by the following steps:
in the detail page of the temp-rise model, select Online Instance.
Select the instance name to open the Model Deployment page and select the Predictor card.
View and copy the Service Calling Address, Feedback Address, and Token of the deployment instance.
Call model services via REST API, for more information, see Call Model Service.
Next Unit¶
Unit 6. Running the Pipeline and Viewing Pipeline Running Results