Search in sources :

Example 1 with PredictionAwareHumanTaskLifeCycle

use of io.automatiko.engine.addons.predictions.api.PredictionAwareHumanTaskLifeCycle in project automatiko-engine by automatiko-io.

the class SmileRandomForestPredictionTest method configure.

@BeforeEach
public void configure() {
    final RandomForestConfiguration configuration = new RandomForestConfiguration();
    final Map<String, AttributeType> inputFeatures = new HashMap<>();
    inputFeatures.put("ActorId", AttributeType.NOMINAL);
    configuration.setInputFeatures(inputFeatures);
    configuration.setOutcomeName("output");
    configuration.setOutcomeType(AttributeType.NOMINAL);
    configuration.setConfidenceThreshold(0.7);
    configuration.setNumTrees(1);
    predictionService = new SmileRandomForest(configuration);
    CachedWorkItemHandlerConfig wiConfig = new CachedWorkItemHandlerConfig();
    wiConfig.register("Human Task", new HumanTaskWorkItemHandler(new PredictionAwareHumanTaskLifeCycle(predictionService)));
    config = new StaticProcessConfig(wiConfig, new DefaultProcessEventListenerConfig(), new DefaultUnitOfWorkManager(new CollectingUnitOfWorkFactory()), null, new DefaultVariableInitializer(), null);
    for (int i = 0; i < 10; i++) {
        predictionService.train(null, Collections.singletonMap("ActorId", "john"), Collections.singletonMap("output", "predicted value"));
    }
    for (int i = 0; i < 8; i++) {
        predictionService.train(null, Collections.singletonMap("ActorId", "mary"), Collections.singletonMap("output", "value"));
    }
}
Also used : HumanTaskWorkItemHandler(io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemHandler) PredictionAwareHumanTaskLifeCycle(io.automatiko.engine.addons.predictions.api.PredictionAwareHumanTaskLifeCycle) StaticProcessConfig(io.automatiko.engine.workflow.StaticProcessConfig) HashMap(java.util.HashMap) DefaultVariableInitializer(io.automatiko.engine.workflow.base.instance.context.variable.DefaultVariableInitializer) CachedWorkItemHandlerConfig(io.automatiko.engine.workflow.CachedWorkItemHandlerConfig) CollectingUnitOfWorkFactory(io.automatiko.engine.services.uow.CollectingUnitOfWorkFactory) DefaultProcessEventListenerConfig(io.automatiko.engine.workflow.DefaultProcessEventListenerConfig) DefaultUnitOfWorkManager(io.automatiko.engine.services.uow.DefaultUnitOfWorkManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PredictionAwareHumanTaskLifeCycle (io.automatiko.engine.addons.predictions.api.PredictionAwareHumanTaskLifeCycle)1 CollectingUnitOfWorkFactory (io.automatiko.engine.services.uow.CollectingUnitOfWorkFactory)1 DefaultUnitOfWorkManager (io.automatiko.engine.services.uow.DefaultUnitOfWorkManager)1 CachedWorkItemHandlerConfig (io.automatiko.engine.workflow.CachedWorkItemHandlerConfig)1 DefaultProcessEventListenerConfig (io.automatiko.engine.workflow.DefaultProcessEventListenerConfig)1 StaticProcessConfig (io.automatiko.engine.workflow.StaticProcessConfig)1 DefaultVariableInitializer (io.automatiko.engine.workflow.base.instance.context.variable.DefaultVariableInitializer)1 HumanTaskWorkItemHandler (io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemHandler)1 HashMap (java.util.HashMap)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1