Load Historical Pump Data Into Monitor
Maximo Predict includes notebook templates that you can use to quickly upload your device data and associate them to newly created assets within Maximo. Out of the box, users are provided with a set of notebooks including multiple different Fast Start Data Loaders. These notebooks vary in what type of data they will be uploading into the Maximo System. In this lab, we will be uploading sensor data for new devices, failure data, and new assets.
In this exercise you will use Watson Studio, Monitor and Predict to:
- Upload historical Data using the FastStart Loader notebook template.
- Run Notebooks to load your device type and device metrics into Monitor and creates Predict groups.
- Confirm Monitor Data Upload and Prediction Groups
- Error Handling for data column name format
Note
You must complete the previous exercise for Data Preparation and Loading Using Notebooks exercise before you start this exercise.
Pre-requisites
- Review Predict documentation for the list of available models.
- Ensure your MAS Predict environment is running and you have access. Try your server URL that might look something like: https://main.predict.ivt11rel87.ivt.suite.myhost.com/ibm/pmi/service/rest/system/info
Upload and Start the Fast Start Data Loader Notebook
-
Upload or open the Fast Start Data Loader template notebook to your Project. These instructions will be based off using the 'FastStart2021-New.ipynb' file. Use the steps from the previous exercise Add Notebook From File to a Watson Studio Project Rename the notebook template by prepending your initials to the template. If you already have uploaded the notebook, open it with Watson Studio. Select the
FastStart2021-New.ipynb
notebook template that you have renamed with your initials. -
Open the notebook. Click on the
pencil
icon next to your notebook -
If the notebook fails to start, restart it. Click on the
i
icon ,Environment
tab,Running status
drop down select box and chooseRestart
Run the Notebook
Part 1 - Introduction
- Run the first cell two cells. These cells are setting up the files required to complete the notebook.
- Read the introduction for details on the notebook and how it fits into the Maximo Predict process. Ensure that your csv files are uploaded in the requested format. Note that the asset metrics csv file needs to have Asset Id, Install Date and Decommission Date, NOT the site ID.
Part 2 - Install the Maximo Predict SDK
- Ensure you have a 'Predict_Envs.json' file uploaded. If one is not provided, follow the instructions in set up Watson Studiounder the 'Get URL' section to gather the
APM_ID
,APM_API_BASE_URL
, andAPM_API_KEY
to create a JSON file containing the credentials and upload to Watson Studio with your initials prepended to the file name. - Run the cell to open the JSON file. If you have created a JSON file with your initials prepended, update
f = open('/project_data/data_asset/Predict_Envs.json,)
to include your initials on the file name. See example image. - Run the following two cells to set up variables required for the environment. Note that both should produce an output without errors similar to
main.predict.ivt11rel87.ivt.suite.maximo.com
- Run the cell to install the pmlib using the pip install command
- Ensure the output runs without errors. (Warnings are Okay) then run the cell to import pmlib into the project
- Run the cell to import the additional required libraries
- Update the following values in the cell with your initials:
- Change
newAssetPrefix = 'New_'
tonewAssetPrefix = '{initials}_'
- Change
default_device_type = 'Pump_AFM'
todefault_device_type = '{initials}_Pump_AFM'
- Change
device_ids_oem = ['PMPDEVICE002', 'PMPDEVICE004', 'PMPDEVICE006', 'PMPDEVICE008', 'PMPDEVICE010']
todevice_ids_oem = ['{initials}_PMPDEVICE00']
- Run the cell and make a note of the resulting output. This will be needed in future notebooks to call your assets.
- Run the following cell to store the variables just created
- Run the cell to set the preferred column names for Maximo's system
Part 3 - Load the Data Into Dataframes
- Update
asset_installation_decommission_dates_df = pd.read_csv('/project_data/data_asset/asset_installation_decommission_date_afm.csv')
to match the filename for your asset information (containing asset id, installation date and decommission date). - If your Installation Date column header or your Decommission date column header do not match the values called in this cell (
installation_date
anddecommission_date
), update to match your column headers. - Run the cell to load the asset attributes and ensure the output matches your data. Note that the column headers in the output should match the variables defined in the previous cell.
- Repeat these steps for each csv file being imported for the remainder of part 3.
- Note: Not all of these cells are redefining the column headers. If you get errors down the line, you may need to update the column header in the data frame created here. See Update DateFrame Headers.
Part 4 - Add Timeshift to Make Data More Recent
- Run the first cell to view the current date range of the data.
- Run the second cell to calculate and view the shift in time that will be applied
- Run the third cell to perform the time shift
- Run the fourth cell to view the new range of dates for the sensor dataframe
- Repeat these steps for the remainder of part 4 to perform the timeshift on the failure data
Part 5 - Clean up DataFrames
- Run these two cells to clean up dataframes and reformat to Maximo's standards
Part 6 - Delete Existing Data
Note
This section is REQUIRED if you are refreshing asset data or uploading new data for an existing asset. If you get errors in this section, you may need to update the column header in the data frame created here. See Update DateFrame Headers.
- Run the first four cells to delete data from Maximo to be replaced. Wait five minutes after the final cell to allow for the data to be fully deleted
- Run the next two cells to delete the asset group
Part 7 - Insert Data
The following steps will update the MAS database to include the data from the CSV files. 1. Run the cell to view the DataFrame to be imported and run the following cell to use the pmlib library to create the assets in the list. 2. Run the cell to view the assets attributes that will be imported into MAS. Run the following cell to update those values. 3. Run the cell to view the failure history that will be imported into MAS. Run the following cell to import the failure data. 4. Run the cell to write the function definitions required to create your asset group. Run the following cell to create teh asset group. 5. Run the cell to print the asset group name and the asset group id. Take a note of the results as they may be needed in future notebooks.
- Run the following cell to store the notebook results
-
Set up the IOT Devices. Update DataFrame columns from
[timestamp_col_name, asset_id_col_name, 'VELOCITYX', 'VELOCITYY', 'VELOCITYZ', 'MOTORTEMP', 'WINDINGTEMP', 'CURRENT', 'PRESSURE', 'LOAD', device_id_col_name, device_type_col_name]
to match the sensor readings for your asset. For example, the line may now read:sensor_data_afm_df.columns = [asset_id_col_name,timestamp_col_name, 'Current_10', 'Speed_4', 'Frequency_2','Current_12','Current_5', 'Vibration_00', 'Current_11','Vibration_13','Power_6','Vibration_1','Power_9','Speed_26',device_id_col_name, device_type_col_name]
-
Run the cell
- Click into the next cell
-
In the menu, go to
Insert > Cell Above
-
In that cell, insert the following code and run:
features_for_training=list(set(list(sensor_data_afm_df.columns))- set(['asset_id','evt_timestamp','deviceid','devicetype'])) features_for_training
-
Update the value of
columns
tocolumns=features_for_training
-
Run the cell and ensure there are no errors
- Run the following cell to import the asset device mappings
- Continue to part 8 or scroll down to run the final cell to save the results.
Part 8 - Add additional Data (Optional)
This portion of the notebook is optional. If there is additional data to be uploaded you can use this section and customize the data being sent to MAS and creating scoring data for your assets. These cells would have to be updated for your data.
Note
Ensure you run the final cell with:
store_json = json.dumps(store)
project.save_data("fast_execution.json", store_json, overwrite=True)
Confirm Data Upload and Prediction Groups
Confirm that the historical data was uploaded to Monitor. Confirm that the Prediction group was created and linked to the model notebook template you created.
- Navigate to Predict within your environment
-
Use the left-hand menu to go into
Predict Grouping
-
Ensure your asset group is available in the list and confirm your asset is available within the group.
-
Navigate to IOT within your environment. Under
devices
, search to ensure yourdevice
is there -
Navigate to
Device Types
and find your device type. Check that yourphysical
andlogical interfaces
are active. -
Navigate to Monitor and ensure your devices have data
Error Handling
Update DateFrame Header
If you receive an object attribute error for pandas, with a column header initialized in Part 2 step 10 listed similar to: Then follow these steps to replace your dataframe header to resolve this error. 1. Click into the cell that resulted in an error.
-
In the menu, go to
Insert > Cell Above
-
Rename the columns by adding the following code in the cell:
{DataFrame_to_Change}.rename(columns={'{current_column_header}': site_id_col_name}, inplace=True)
{DataFrame_to_Change}.head()
-
Run the cell. The output should show the new header in the table. For example: in order to change the
failure_data_afm_df
column header from'site'
to the preferred header:
Congratulations you have loaded historical data and created Predict Groups linking your devices metrics inputs to list of assets and notebook template that will be used to score predictions using Predict with Monitor device data!