Building prediction models
The data of your organization contains highly valuable information that you can use to help you make better decisions. Use prediction models to compute a prediction that you can use to make a decision.
When you create a prediction model, a basic diagram that contains all the elements that are needed to compute a prediction is generated automatically:

The first step after creating a prediction model is to configure it so it knows which model to use. Several options are available when configuring a prediction mode:
- Connect to a remote machine learning provider and call a machine learning model hosted outside of watsonx Orchestrate.
- Connect to a machine learning provider and upload a Predictive Model Markup Language (PMML) file. This option is available for both remote and embedded providers.
- Import a scorecard or ruleset model and run it locally.
Then, you update the diagram to map input and output types from the machine learning model to data types available in your project.
Managing providers
Three remote providers are supported: IBM Watson® Machine Learning, Amazon® SageMaker, and IBM® Open Prediction Service.
Open Prediction Service is an extension framework that allows you to connect to machine learning providers that are not natively supported. This includes custom machine learning services and third-party machine learning tools, such as Microsoft Azure Machine Learning. For more information about Open Prediction Service, see the Open Prediction Service Hub repository.
An embedded machine learning provider is also supported. This provider allows you to import any type of Predictive Model Markup Language (PMML) file and run it directly in your project.
To add providers:
- From your project, open the Settings
menu.
- Click the New + button.
- Select a provider type in the drop-down menu and enter a name for the provider.
- Enter the credentials for the provider. The following table provides details for each provider type:
Provider | Credentials |
---|---|
Watson™ Machine Learning IBM Cloud Identity and Access Management (IAM) |
Enter the following service credentials to authenticate with your Watson Machine Learning service instance: - API key - Space ID - Authentication URL - URL This information can be found on Watson Studio. The Authentication URL is populated with a default value automatically. |
Watson™ Machine Learning User Management Service (UMS) |
Enter the following service credentials to authenticate with your Watson Machine Learning service instance: - API key - Space ID - Authentication URL - User - Password This information can be found on Watson Studio. |
Watson™ Machine Learning Platform UI (Zen) |
Enter the following service credentials to authenticate with your Watson Machine Learning service instance: - API key - Space ID - User - API key This information can be found on Watson Studio. |
Amazon SageMaker | Enter the following service credentials to authenticate with your Amazon SageMaker instance: - Region - Access key ID - Access key value |
Open Prediction Service | Enter the URL of your Open Prediction Service instance. |
Embedded Machine Learning | No credentials needed. |
- Click Save
Configuring prediction models
A wizard guides you through a step-by-step process to configure your prediction model. To launch the wizard, click the Configure button in the right-side panel of the prediction model.
Calling a remote machine learning model
You can select the deployment of a machine learning model that is hosted on a remote provider service. This deployment is used to generate a pre-filled prediction model.
-
In the wizard, select Remote machine learning and click Next.
-
Select the provider where the machine learning model that you want to call is stored from the drop-down list.
-
In the list of deployments available, click the arrow next to the machine learning model that you want to use to expand it. Then, select the deployment.
-
Click Next to define the input parameters that are needed to make the prediction.
If an input schema is automatically generated by the provider, you can edit it if necessary. You can update or delete existing parameters, and add new ones. If no schema is generated, you can:
- Work in the Form tab or in the JSON tab and manually define the input schema.
- Use a JSON payload to generate a pre-populated schema by clicking Generate from payload and pasting a JSON payload. The generated schema is editable.
-
Click Next to test the model invocation.
This step is optional and allows you to make sure that the model returns the expected results when called. If the model does not return the expected results, you can go back to the previous step to edit the input schema as required.
-
Click Next to define the output values of the prediction. To define the output schema, you can:
- Work in the Form tab or in the JSON tab and manually define the input schema.
- Use a JSON payload to generate a pre-populated schema by clicking Generate from payload and pasting a JSON payload. The generated schema is editable.
- Use the output of the invocation test to generate a pre-populated schema. The generated schema is editable. This option is available only if you tested the model invocation.
-
Click Apply.
Uploading a Predictive Model Markup Language (PMML) file
Using this option, you can:
- Select a remote machine learning provider and upload a serialized machine learning model.
- Select the embedded machine learning provider and upload any type of PMML file.
-
In the wizard, select Remote machine learning and click Next.
-
Select a machine learning provider from the drop-down list.
-
Click Upload and drag your file into the drop target area.
-
Click Next to define the input parameters that are needed to make the prediction.
If an input schema is automatically generated by the provider, you can edit it if necessary. You can update or delete existing parameters, and add new ones. If no schema was generated, you can:
- Work in the Form tab or in the JSON tab and manually define the input schema.
- Use a JSON payload to generate a pre-populated schema by clicking Generate from payload and pasting a JSON payload. The generated schema is editable.
-
Click Next to test the model invocation.
This step is optional and allows you to make sure that the model returns the expected results when it runs. If the model does not return the expected results, you can go back to the previous step to edit the input schema as required.
-
Click Next to define the output values of the prediction. To define the output schema, you can:
- Work in the Form tab or in the JSON tab and manually define the input schema.
- Use a JSON payload to generate a pre-populated schema by clicking Generate from payload and pasting a JSON payload. The generated schema is editable.
- Use the output of the invocation test to generate a pre-populated schema. The generated schema is editable. This option is available only if you tested the model invocation.
-
Click Apply.
Importing a transparent machine learning model
You can use the wizard to upload ruleset models and scorecard models from your file system. Transparent machine learning models must have either the .pmml
or the .xml
file format.
In ruleset models, historical data is used to generate a set of rules which, when executed, returns predictions. When you import a ruleset model, the rules it contains can either be transformed into business rules or decision tables.
In scorecard models, metrics are used to compute a score reflecting a probability. This type of model is used, for example, to compute credit scores. When you import a scorecard model, it is recommended to import it as a decision table.
-
In the wizard, select Local machine learning model and click Next.
-
Drag your file into the drop target area in the wizard.
-
Select the decision logic generation method that is best suited to the type of model you imported: business rules or decision tables. Then, click Next.
-
The list of data types that are required by the machine learning model displays. Use the interactive mapping wizard to directly map these data types to data types from the data model in your project:
- Click any source data type to start mapping it.
- Follow the mapping instructions: select a data type from your data model and an expression to map the source type to.
- If the source type contains attributes, map them to data types from your data model.
This step is optional. If you prefer not use the interactive wizard, you can map input data types manually by following the procedure that is described in Mapping inputs.
-
Click Apply.
Updating the diagram
When you configure the prediction model, a data model is also created. It contains the data types that the machine learning model expects as input, and the data type of the prediction is returns. You need to map those data types to pre-built or custom data types available in your project.
Mapping inputs
-
List the data types that are used by the machine learning model. If you do not have this information, you might need to work with the data scientist who created the machine learning model.
-
In your prediction model, add an input node for each data type that the model needs to make the prediction.
- In the diagram toolbar, click Add input
to create an input node.
- Configure the node: give it a name and select a data type from the list.
- Link the input node to the input mapping node.
- In the diagram toolbar, click Add input
-
Select the input mapping node and open the Logic tab.
-
Map the input types by using business rules and decision tables.
- If the mapping is between two data types that are the same except for their name, the mapping is straightforward. In this case, you write a rule statement that looks like this:
set the age of decision to the age of patient
- You can also write a rule statement that maps multiple data types:
set decision to a new ML model input where the age is the age of patient , the gender is the gender of patient , the systolicbloodpressure is the systolic blood pressure of patient , the diastolicbloodpressure is the diastolic blood pressure of patient ;
For more information about business rules and decision tables, see Authoring the decision logic.
Mapping outputs
-
Select the output mapping node and open the Logic tab.
-
Create a business rule or decision table to map the output type. If the prediction returns a score, you do not need to map it to a data type because it already corresponds to a pre-built data type. In the case where no mapping is needed, you write a simple rule statement that retrieves the output of the machine learning model:
set decision to the prediction of 'ML model invocation' ;
-
(Optional) You can also add a rule to set an error code and an error message.
For example:
if 'ML model invocation' is in error then set decision to the code of the error + "-" + the message of 'ML model invocation' ; else set decision to the prediction of 'ML model invocation' ;
For more information about the error codes and messages, see Error codes in prediction model outputs.
What to do next
You can preview your prediction model to make sure that it works as expected.
When you're finished building your prediction model, you can:
- Click the icon
to make your skill public. Only public skills can be published to the skill catalog.
- Share your changes to make them available to your collaborators.
- Use the output of the prediction in decision models, ruleflow models, or workflows.
Parent topic: