Apama Predictive Analytics Plug-in 10.5 | Apama Predictive Analytics Plug-in Documentation 10.5 | Working with Predictive Analytics Plug-in | Managing PMML models
 
Managing PMML models
The Predictive Analytics Plug-in supports adding, updating, activating, and removing a PMML model at runtime.
* To add, update, activate or remove a model in an EPL script
1. The Predictive Analytics Plug-in also supports managing resources at runtime through ModelManager API. ModelManager API can be accessed by calling getModelManager() on the ServiceHandler object received in service initialisation onServiceInitialised callback.
action onServiceInitialised(ServiceHandler servicehandler)
{
ModelManager modelmanager := serviceHandler.getModelManager();

//Add Model1 from PMML_PATH1
modelmanager.addModel("PMML_PATH1");

//Add Model2 from PMML_PATH2
modelmanager.addModel("PMML_PATH2");
...
...

//Update Model1 from another source PMML_PATH3
modelmanager.updateModel("Model1","PMML_PATH3");
...
...

//remove model when done
modelmanager.removeModel("Model1");
modelmanager.removeModel("Model2");
}
Any errors are reported through default callback onServiceError of service handler.
You can add custom callbacks for the above mentioned functions as described below:
action onServiceInitialised(ServiceHandler servicehandler)
{
ModelManager modelmanager := serviceHandler.getModelManager();

//Add Model1 from PMML_PATH1
modelmanager.addModelCb("PMML_PATH1", onStatus);

//Add Model2 from PMML_PATH2
modelmanager.addModelCb("PMML_PATH2", onStatus);
...
...

//Update Model1 from another source PMML_PATH3
modelmanager.updateModelCb("Model1","PMML_PATH3", onStatus);
...
...

//Deactivate Model1
Model model1 := serviceHandler.getModel("Model1")
if(model1.isActive()) {
model1.setActive(false)
}
...
...

//remove model when done
modelmanager.removeModelCb("Model1", onStatus);
modelmanager.removeModelCb("Model2", onStatus);

}

action onStatus(ServiceError serviceError)
{
log "Received status on configured callback:
"+serviceError.getErrorMessage();
}

For more information, see API Reference for Predictive Analytics Plug-in EPL (ApamaDoc).
For more information, refer to the samples at APAMA_HOME/samples/PredictiveAnalytics/EnergyData ModelManager

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.