Forecast Custom Scores Using a Machine Learning Model
Health and Predict - Utilities allows you to train a WML model based using an asset's historical score values so that you can forecast future asset scores. MAS Health and Predict Utilities supports forecasting Asset Risk, End of Life scores and Health scores. User can enable forecast by setting two parameters:
``healthlib`.set_FutureScore_enablement(enablement=True)`
``healthlib`.set_FutureScore_numOfyear(numOfyear=10)`
These can parameters can be set in any notebook and saved. The Health Library will calculate the EOL future score as EOL curve.
Risk is calculated as Criticality * EOL. Once an adequate number of historical score samples are available, a future
EOL score and Risk score can be forecasted.
To forecast Health score, MAS Health and Predict Utilities can use a Predict model notebook template to train a model based on historical score data, and register the notebook job in WML to get future scores. MAS Health and Predict Utilities has two notebooks and one cfg file templates.
- IBM-Asset-HealthScore-Forecast-Sample-6.0.0.ipynb is for training and register a forecast model
- IBM-future-score-from-predict-sample-6.0.0.ipynb and IBM-future-score-from-predict-sample-6.0.0.cfg are for creating a Substation Transformer Score Group which includes forecast Health score.
The Predict model notebook template can also be used to forecast other custom score if it has historical scores to train on.
In this set of exercises you will use Watson Studio, MAS Health and Predict Utilities to:
1. Create Score Group Create a Substation Transformer Score Group using IBM-future-score-from-predict-sample-6.0.0.ipynb notebook which include the logic to do Health Score forecast based on wml model.
2. Train WML Model Use IBM-Asset-HealthScore-Forecast-Sample-6.0.0.ipynb template to train a forecast model and register in wml.
3. Schedule Calculation Schedule calculation in Score Group detail page.
4. Check Future Score in Matrix Future scores have been forecasted.
5. Handle Errors that may come up in the process.
Pre-requisites
Ask your instructor:
- For the asset data files for the MAS Health and Predict Utilities Demo Data.
- If they have loaded the hpu_csv_demo data or hpu_csv_st into the Health and Predict Utilities system by completing the Load Data into Manage lab for the Utilities data.
- If a data scientist has prepared the cfg and notebook template for forecasting future scores. in the cfg template, Health calculate method is replaced to use calculate_health_score, and in notebook template register calculate_health_score function, this function can handle both current and future scores.

Note
This forecast notebook template that that deployed along with HPU are the Substation Transformers templates.
User need refer to the template to customize their own cfg and notebook for other Asset Types or Scores.
Create a Score Group Using a Notebook Template
In this step, you will create a custom score using the Connecting group to notebook option to connect to the
IBM-future-score-from-predict-sample-6.0.0 notebook. You will use the query function to identify the Substation
Transformer assets in the group then create the group.
-
From the left cascading menu click
Scoring and DGA settings. Click theGroupstab.
-
Click button
Create a scoring and DGA groupand fill in the form, select a query that matches the assets you would like to include in this group. Search for theQuery nameand clickApplybutton. If you don't see one that fits your need create a query to choose the right assets to add your score to.
-
Click
Createbutton to create and review the assets in the scored assets list to ensure the assets you want to have this score in are are listed.
-
Click into the score and active it one by one.
-
After activating it, it should have a
Yin the column namedActive.
Train WML Model
-
Login to Watson Studio, and open your project.
-
Find the training template
IBM-Asset-HealthScore-Forecast-Sample-6.0.0.ipynb. Click on the notebook name and then click on thepencilicon next to your notebook to open it in edit mode. -
If the notebook fails to start, restart it. Click on the
iicon ,Environmenttab,Running statusdropdown select box and chooseRestart.
-
Update the first code cell to fill in the env connection information including
maximoUrl,maximoApiKey,expgroupname
a.maximoUrlcan be extracted from health or manage url, e.g Get main.manage.ivt13rel88.ivt.suite.maximo.com from https://main.manage.ivt13rel88.ivt.suite.maximo.com/maximo/oslc/graphite/relengineer/index.html".
b.maximoApiKeycan be found by go to "Application Administration -> Search and enter the API Keys application, then copy key from admin user card.
c.expgroupnameis the group id which you can find in the group detail page.
-
Update the cfg file name in below two cells if you have customized your own customized future score notebook and cfg based on the
IBM-future-score-from-predict-sample-6.0.0.ipynbandIBM-future-score-from-predict-sample-6.0.0.cfgtemplates.

-
Create a deployment space to match the one used the below cell.

If you change the default name space, then also need change the deployment space in
IBM-future-score-from-predict-sample-6.0.0.ipynband save to the latest version.
-
Prepare a Predict_Envs.json follow the instruction as it's used in the notebook.

-
Run the first code cell to set the
maximo_context. -
Run the next 13 cells to import and install the required packages including
healthlib
usehealthlibto export Health historical scores into a csv file. -
In the last cell, you'll see the historical scores printed, and also can see the file is registered in the watson studio's data asset.
-
Run the next 6 cells to set some env variables and install
pmilib. In MAS v8.9pmilibshould be added to your Watson Studio project if you have followed these Setup Watson Studio for Predict instructions -
Skip the next cell which is scenario 1 using multiple csv files for each asset's training.
-
Run the next cell which is scenario 2 to set some basic parameters for training, you can update the
pred_winunderparams, by default, it will predict next 5 years' future score.
-
Run the next cell to train the model, it will take some time cause each asset will need to be trained, you can run the following cell multiple times to check the training status.

-
After training is done, you will see a number that matches the total number of assets.

-
Run the remaining cells to register model in WML.If some error when running 34th cell, please ignore and continue run the rest cells.

Trigger Calculation
The following steps will trigger the forecast for the created Score Group.
-
Navigate to
Maximo Health and Predict for Utilitiesfor the provided environment -
Go to the
Scoring and DGA Settingsapplication withinMaximo Health and Predict for Utilities -
Search for the Score Group created before.
-
Click into the Score Group detail, click
Calculate Scoresand allow the scores to calculate. Wait 15 minutes for the calculation to complete.
Check Future Score in Matrix
The following steps will confirm that the future score are forecasted, check future score in Matrix Page similar to earlier in the exercises.
-
Navigate to
Maximo Health and Predict for Utilitiesfor the provided environment. -
Go to the
Scoring and DGA Settingsapplication withinMaximo Health and Predict for Utilities. -
Search for the
Score Groupcreated before.
-
Click into any
assetand confirm that the scores have been calculated.
-
Check future scores in Matrix.
Go to Assets page, select the same query that is used in score group. And clickMatrixicon to switch toMatrixpage.
-
Click year plus button to check the summary information for future year, e.g 2023
-
Click any cell to drill in to see the related assets in a table view. Click year plus button to see which assets are in this range in next year and also show the next year score in the table.
Congratulations you have seen how to use notebook train a WML model, forecast future custom scores and confirmed the future score values in Matrix page.