(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


  1. Log in to EnOS Management Console and select AI Studio > AI Hub from the left navigation pane.

  2. Select New Model on the AI Hub page.

  3. 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.


  4. Configure the following information in the Input/Output section.


    Field Description
    API Type Select REST.
    Configuration Type Select Customized JSON.


  5. 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
       }
    ]
    }
    
  6. 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


  1. Select Data Analytics > AI Studio > AI Lab on the left navigation pane.

  2. Open the temp-rise Notebook instance you created in Unit 3. Preparing Codes.

  3. On a terminal window, enter and run cd_temp_rise and pip install -r requirements.txt --user​ to install dependencies.

  4. Select temp_rise > Train.ipynb to open the file.

  5. Select the double-arrow icon i_rerun on the tool bar to restart kernel and re-run the whole notebook.

  6. After running the Train.ipynb file, select the menu icon i_menu on the lower right corner then select Go to Lab i_gotolab of the running record.

  7. In the Artifacts section, select the temp_rise folder, and select New Version on the right.

  8. 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.

  9. Select Next, the model will be built automatically.

  10. After the model was built, select Next 2 times to go to the Deployment Test page.

  11. 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
         ]
      ]
    }
    }
    
  12. 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:

  1. Select Online Instance > New Instance in the detail page of the temp-rise model.

  2. Configure the following information in the New Deployment Instance popup window.


    Field Description
    Instance Name Enter temp-rise-instance.
    Resource Pool Select notebook.


  3. Select Confirm and the instance appears on the instance list.

  4. Select the instance name to open the Model Deployment page, then select Configure.

  5. Select Add the version to be deployed, and select teh model version from the dropdown list then select OK.

  6. 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:

  1. Select Online Instance in the detail page of the temp-rise model.

  2. Select Test i_bug to open the Usability Test page.

  3. 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:

  1. in the detail page of the temp-rise model, select Online Instance.
  2. Select the instance name to open the Model Deployment page and select the Predictor card.
  3. View and copy the Service Calling Address, Feedback Address, and Token of the deployment instance.
  4. Call model services via REST API, for more information, see Call Model Service.