Search in sources :

Example 1 with PredictionAwareHumanTaskLifeCycle

use of org.kie.kogito.prediction.api.PredictionAwareHumanTaskLifeCycle in project kogito-runtimes by kiegroup.

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);
    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(org.jbpm.process.instance.impl.humantask.HumanTaskWorkItemHandler) PredictionAwareHumanTaskLifeCycle(org.kie.kogito.prediction.api.PredictionAwareHumanTaskLifeCycle) StaticProcessConfig(org.kie.kogito.process.impl.StaticProcessConfig) HashMap(java.util.HashMap) CachedWorkItemHandlerConfig(org.kie.kogito.process.impl.CachedWorkItemHandlerConfig) CollectingUnitOfWorkFactory(org.kie.kogito.services.uow.CollectingUnitOfWorkFactory) DefaultProcessEventListenerConfig(org.kie.kogito.process.impl.DefaultProcessEventListenerConfig) DefaultUnitOfWorkManager(org.kie.kogito.services.uow.DefaultUnitOfWorkManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

HashMap (java.util.HashMap)1 HumanTaskWorkItemHandler (org.jbpm.process.instance.impl.humantask.HumanTaskWorkItemHandler)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 PredictionAwareHumanTaskLifeCycle (org.kie.kogito.prediction.api.PredictionAwareHumanTaskLifeCycle)1 CachedWorkItemHandlerConfig (org.kie.kogito.process.impl.CachedWorkItemHandlerConfig)1 DefaultProcessEventListenerConfig (org.kie.kogito.process.impl.DefaultProcessEventListenerConfig)1 StaticProcessConfig (org.kie.kogito.process.impl.StaticProcessConfig)1 CollectingUnitOfWorkFactory (org.kie.kogito.services.uow.CollectingUnitOfWorkFactory)1 DefaultUnitOfWorkManager (org.kie.kogito.services.uow.DefaultUnitOfWorkManager)1