use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testIntegerFactory.
@Test
void testIntegerFactory() {
final int value = 5;
final FeatureDomain domain = NumericalFeatureDomain.create(0.0, 10.0);
final Feature feature = FeatureFactory.newNumericalFeature("int-feature", value, domain);
final CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof IntegerEntity);
assertEquals(value, counterfactualEntity.asFeature().getValue().asNumber());
}
use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testVectorFactory.
@Test
void testVectorFactory() {
final double[] value = new double[10];
Arrays.fill(value, 1d);
final Feature feature = FeatureFactory.newVectorFeature("uri-feature", value);
CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof FixedVectorEntity);
assertEquals(Type.VECTOR, counterfactualEntity.asFeature().getType());
}
use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testFixedLongFactory.
@Test
void testFixedLongFactory() {
final long value = 5;
final Feature feature = FeatureFactory.newNumericalFeature("long-feature", value);
final CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertNotNull(counterfactualEntity);
assertTrue(counterfactualEntity instanceof FixedLongEntity);
assertEquals(value, counterfactualEntity.asFeature().getValue().asNumber());
}
use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testFixedBooleanFactory.
@Test
void testFixedBooleanFactory() {
final boolean value = false;
final Feature feature = FeatureFactory.newBooleanFeature("bool-feature", value);
final CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof FixedBooleanEntity);
assertEquals(value, counterfactualEntity.asFeature().getValue().getUnderlyingObject());
}
use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testCompositeFactory.
@Test
void testCompositeFactory() {
Map<String, Object> map = new HashMap<>();
List<Feature> features = new LinkedList<>();
features.add(FeatureFactory.newObjectFeature("f1", new Object()));
features.add(FeatureFactory.newTextFeature("f2", "hola"));
features.add(FeatureFactory.newFulltextFeature("f3", "foo bar"));
features.add(FeatureFactory.newNumericalFeature("f4", 131));
features.add(FeatureFactory.newBooleanFeature("f5", false));
features.add(FeatureFactory.newDurationFeature("f6", Duration.ofDays(2)));
Map<String, Object> nestedMap = new HashMap<>();
nestedMap.put("nf-1", "nested text");
nestedMap.put("nf-2", ByteBuffer.allocate(1024));
features.add(FeatureFactory.newCompositeFeature("f7", nestedMap));
for (Feature f : features) {
map.put(f.getName(), f.getValue().getUnderlyingObject());
}
final Feature feature = FeatureFactory.newCompositeFeature("composite-feature", map);
CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof FixedCompositeEntity);
assertEquals(Type.COMPOSITE, counterfactualEntity.asFeature().getType());
}
Aggregations