use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemHandler 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"));
}
}
use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemHandler in project automatiko-engine by automatiko-io.
the class PredictionAwareHumanTaskLifeCycleTest method configure.
@BeforeEach
public void configure() {
predictNow = new AtomicBoolean(false);
trainedTasks = new ArrayList<>();
predictionService = new PredictionService() {
@Override
public void train(io.automatiko.engine.api.runtime.process.WorkItem task, Map<String, Object> inputData, Map<String, Object> outputData) {
trainedTasks.add(task.getId());
}
@Override
public PredictionOutcome predict(io.automatiko.engine.api.runtime.process.WorkItem task, Map<String, Object> inputData) {
if (predictNow.get()) {
return new PredictionOutcome(95, 75, Collections.singletonMap("output", "predicted value"));
}
return new PredictionOutcome();
}
@Override
public String getIdentifier() {
return "test";
}
};
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);
}
Aggregations