use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testFixedCategoricalEntity.
@Test
void testFixedCategoricalEntity() {
final String value = "foo";
final Feature feature = FeatureFactory.newCategoricalFeature("categorical-feature", value);
final CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof FixedCategoricalEntity);
assertEquals(value, counterfactualEntity.asFeature().getValue().toString());
}
use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testLongFactory.
@Test
void testLongFactory() {
final long value = 5;
final FeatureDomain domain = NumericalFeatureDomain.create(0.0, 10.0);
final Feature feature = FeatureFactory.newNumericalFeature("long-feature", value, domain);
final CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertNotNull(counterfactualEntity);
assertTrue(counterfactualEntity instanceof LongEntity);
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 testCategoricalFactoryObject.
@Test
void testCategoricalFactoryObject() {
final String value = "foo";
final FeatureDomain domain = CategoricalFeatureDomain.create("foo", "bar");
final Feature feature = FeatureFactory.newCategoricalFeature("categorical-feature", value, domain);
final CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof CategoricalEntity);
assertEquals(domain.getCategories(), ((CategoricalEntity) counterfactualEntity).getValueRange());
assertEquals(value, counterfactualEntity.asFeature().getValue().toString());
}
use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testTextFactory.
@Test
void testTextFactory() {
final String value = "foo";
final Feature feature = FeatureFactory.newTextFeature("text-feature", value);
CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof FixedTextEntity);
assertEquals(Type.TEXT, counterfactualEntity.asFeature().getType());
final Feature varyingFeature = FeatureFactory.newTextFeature("text-feature", value, EmptyFeatureDomain.create());
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
CounterfactualEntityFactory.from(varyingFeature);
});
assertEquals("Unsupported feature type: text", exception.getMessage());
}
use of org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testBooleanFactory.
@Test
void testBooleanFactory() {
final boolean value = false;
final Feature feature = FeatureFactory.newBooleanFeature("bool-feature", value, EmptyFeatureDomain.create());
final CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof BooleanEntity);
assertEquals(value, counterfactualEntity.asFeature().getValue().getUnderlyingObject());
}
Aggregations