Machine learning services

When a decision service needs to access machine learning services, it must specify certain parameters for each service in the value of the key decisionMedatata in the run context of the DecisionRunner instance.

The value corresponding to the decisionMedata is an ObjectNode. Each of this field corresponds to a machine learning service.

The following example passes parameters for the machine learning service called myMLService:
DecisionRunner runner = ..;

String executionId = ..; // the unique identifier of the execution

String providerInfoId = "rfc-info";
String providerId = "lml"; // the name of the ML provider
String providerInfo = "{\"id\": \"+ providerInfoId + \", \"providerId\": \" + providerId + \", \"deploymentId\": \"v0\"}";
String provider = "{ \"mlUrl\": \"http://0.0.0.0:8080\", \"type\": \"OPS\", \"name\": \" + providerId + \", \"instanceId\": \"v0\"}"

ObjectMapper mapper = (ObjectMapper) context.get(ObjectMapper.class.getName());
Object inData = ..;

ObjectNode decisionMetadata = mapper.createObjectNode();
decisionMetadata.put(providerInfoId, providerInfo);
decisionMetadata.put(providerId, provider);

RunContext context = runner.createRunContext(executionId);
context.put("decisionMetadata", decisionMetadata);

runner.execute(inData, context);

providerInfoId must be the same as the one in the providerInfo.json file in the resources/extannotations/<packageName>/ folder for the predictive model.

  • If the execution uses the same deployment of the same machine learning provider as the one that is used in the authoring environment, the provider information can be found in the provider.json file in the resources/extannotations/<packageName>/ folder for the predictive model, except for apiKey if it is of the type WML.

    This machine learning deployment must exist on the same machine learning provider. It might be checked either in the Automation Decision Services authoring environment or in the machine learning provider interface.

  • When you use another deployment, deploymentId and mlUrl must be changed accordingly. If the provider type is WML, then authUrl, apiKey, and instanceId must be filled as well. The instanceId is the spaceId for Watson® Machine Learning, where the machine learning model is deployed.

For more information about parameters for machine learning services, see the Mandatory metadata for invoking machine learning services section in Decision service metadata.

Optionally, you can specify SSLContext that is used to communicate with the machine learning services:
import javax.net.ssl.SSLContext;
[..]
context.put(SSLContext.class.getName(), sslContext);