use of org.kie.kogito.explainability.model.DataDomain in project kogito-apps by kiegroup.
the class CounterfactualExplainerTest method testNoCounterfactualPossible.
@ParameterizedTest
@ValueSource(ints = { 0, 1, 2 })
void testNoCounterfactualPossible(long seed) throws ExecutionException, InterruptedException, TimeoutException {
Random random = new Random();
final PerturbationContext perturbationContext = new PerturbationContext(seed, random, 4);
final List<Output> goal = List.of(new Output("inside", Type.BOOLEAN, new Value(true), 0.0));
List<Feature> features = new LinkedList<>();
List<FeatureDomain> featureBoundaries = new LinkedList<>();
List<Boolean> constraints = new LinkedList<>();
features.add(FeatureFactory.newNumericalFeature("f-num1", 1.0));
constraints.add(true);
featureBoundaries.add(EmptyFeatureDomain.create());
features.add(FeatureFactory.newNumericalFeature("f-num2", 1.0));
constraints.add(false);
featureBoundaries.add(NumericalFeatureDomain.create(0.0, 2.0));
features.add(FeatureFactory.newNumericalFeature("f-num3", 1.0));
constraints.add(false);
featureBoundaries.add(NumericalFeatureDomain.create(0.0, 2.0));
features.add(FeatureFactory.newNumericalFeature("f-num4", 1.0));
constraints.add(true);
featureBoundaries.add(EmptyFeatureDomain.create());
final DataDomain dataDomain = new DataDomain(featureBoundaries);
final double center = 500.0;
final double epsilon = 1.0;
List<Feature> perturbedFeatures = DataUtils.perturbFeatures(features, perturbationContext);
final CounterfactualResult result = runCounterfactualSearch((long) seed, goal, perturbedFeatures, TestUtils.getSumThresholdModel(center, epsilon), DEFAULT_GOAL_THRESHOLD);
assertFalse(result.isValid());
}
Aggregations