Search in sources :

Example 16 with FeatureDomain

use of org.kie.kogito.explainability.model.domain.FeatureDomain in project kogito-apps by kiegroup.

the class FeatureDomainTest method isEmpty.

@Test
void isEmpty() {
    final FeatureDomain domain = EmptyFeatureDomain.create();
    assertNull(domain.getCategories());
    assertNull(domain.getLowerBound());
    assertNull(domain.getUpperBound());
    assertTrue(domain.isEmpty());
}
Also used : CategoricalFeatureDomain(org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) EmptyFeatureDomain(org.kie.kogito.explainability.model.domain.EmptyFeatureDomain) FeatureDomain(org.kie.kogito.explainability.model.domain.FeatureDomain) Test(org.junit.jupiter.api.Test)

Example 17 with FeatureDomain

use of org.kie.kogito.explainability.model.domain.FeatureDomain in project kogito-apps by kiegroup.

the class CounterfactualEntityFactoryTest method testCategoricalFactoryList.

@Test
void testCategoricalFactoryList() {
    final String value = "foo";
    final FeatureDomain domain = CategoricalFeatureDomain.create(List.of("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());
}
Also used : CounterfactualEntity(org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity) ObjectFeatureDomain(org.kie.kogito.explainability.model.domain.ObjectFeatureDomain) EmptyFeatureDomain(org.kie.kogito.explainability.model.domain.EmptyFeatureDomain) CategoricalFeatureDomain(org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain) CurrencyFeatureDomain(org.kie.kogito.explainability.model.domain.CurrencyFeatureDomain) URIFeatureDomain(org.kie.kogito.explainability.model.domain.URIFeatureDomain) DurationFeatureDomain(org.kie.kogito.explainability.model.domain.DurationFeatureDomain) TimeFeatureDomain(org.kie.kogito.explainability.model.domain.TimeFeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) BinaryFeatureDomain(org.kie.kogito.explainability.model.domain.BinaryFeatureDomain) FeatureDomain(org.kie.kogito.explainability.model.domain.FeatureDomain) CategoricalEntity(org.kie.kogito.explainability.local.counterfactual.entities.CategoricalEntity) FixedCategoricalEntity(org.kie.kogito.explainability.local.counterfactual.entities.fixed.FixedCategoricalEntity) Feature(org.kie.kogito.explainability.model.Feature) Test(org.junit.jupiter.api.Test)

Example 18 with FeatureDomain

use of org.kie.kogito.explainability.model.domain.FeatureDomain 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());
}
Also used : CounterfactualEntity(org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity) IntegerEntity(org.kie.kogito.explainability.local.counterfactual.entities.IntegerEntity) FixedIntegerEntity(org.kie.kogito.explainability.local.counterfactual.entities.fixed.FixedIntegerEntity) ObjectFeatureDomain(org.kie.kogito.explainability.model.domain.ObjectFeatureDomain) EmptyFeatureDomain(org.kie.kogito.explainability.model.domain.EmptyFeatureDomain) CategoricalFeatureDomain(org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain) CurrencyFeatureDomain(org.kie.kogito.explainability.model.domain.CurrencyFeatureDomain) URIFeatureDomain(org.kie.kogito.explainability.model.domain.URIFeatureDomain) DurationFeatureDomain(org.kie.kogito.explainability.model.domain.DurationFeatureDomain) TimeFeatureDomain(org.kie.kogito.explainability.model.domain.TimeFeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) BinaryFeatureDomain(org.kie.kogito.explainability.model.domain.BinaryFeatureDomain) FeatureDomain(org.kie.kogito.explainability.model.domain.FeatureDomain) Feature(org.kie.kogito.explainability.model.Feature) Test(org.junit.jupiter.api.Test)

Example 19 with FeatureDomain

use of org.kie.kogito.explainability.model.domain.FeatureDomain 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());
}
Also used : CounterfactualEntity(org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity) FixedLongEntity(org.kie.kogito.explainability.local.counterfactual.entities.fixed.FixedLongEntity) LongEntity(org.kie.kogito.explainability.local.counterfactual.entities.LongEntity) ObjectFeatureDomain(org.kie.kogito.explainability.model.domain.ObjectFeatureDomain) EmptyFeatureDomain(org.kie.kogito.explainability.model.domain.EmptyFeatureDomain) CategoricalFeatureDomain(org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain) CurrencyFeatureDomain(org.kie.kogito.explainability.model.domain.CurrencyFeatureDomain) URIFeatureDomain(org.kie.kogito.explainability.model.domain.URIFeatureDomain) DurationFeatureDomain(org.kie.kogito.explainability.model.domain.DurationFeatureDomain) TimeFeatureDomain(org.kie.kogito.explainability.model.domain.TimeFeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) BinaryFeatureDomain(org.kie.kogito.explainability.model.domain.BinaryFeatureDomain) FeatureDomain(org.kie.kogito.explainability.model.domain.FeatureDomain) Feature(org.kie.kogito.explainability.model.Feature) Test(org.junit.jupiter.api.Test)

Example 20 with FeatureDomain

use of org.kie.kogito.explainability.model.domain.FeatureDomain 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());
}
Also used : CounterfactualEntity(org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity) ObjectFeatureDomain(org.kie.kogito.explainability.model.domain.ObjectFeatureDomain) EmptyFeatureDomain(org.kie.kogito.explainability.model.domain.EmptyFeatureDomain) CategoricalFeatureDomain(org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain) CurrencyFeatureDomain(org.kie.kogito.explainability.model.domain.CurrencyFeatureDomain) URIFeatureDomain(org.kie.kogito.explainability.model.domain.URIFeatureDomain) DurationFeatureDomain(org.kie.kogito.explainability.model.domain.DurationFeatureDomain) TimeFeatureDomain(org.kie.kogito.explainability.model.domain.TimeFeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) BinaryFeatureDomain(org.kie.kogito.explainability.model.domain.BinaryFeatureDomain) FeatureDomain(org.kie.kogito.explainability.model.domain.FeatureDomain) CategoricalEntity(org.kie.kogito.explainability.local.counterfactual.entities.CategoricalEntity) FixedCategoricalEntity(org.kie.kogito.explainability.local.counterfactual.entities.fixed.FixedCategoricalEntity) Feature(org.kie.kogito.explainability.model.Feature) Test(org.junit.jupiter.api.Test)

Aggregations

FeatureDomain (org.kie.kogito.explainability.model.domain.FeatureDomain)39 NumericalFeatureDomain (org.kie.kogito.explainability.model.domain.NumericalFeatureDomain)38 Test (org.junit.jupiter.api.Test)32 EmptyFeatureDomain (org.kie.kogito.explainability.model.domain.EmptyFeatureDomain)31 Feature (org.kie.kogito.explainability.model.Feature)29 CategoricalFeatureDomain (org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain)25 CounterfactualEntity (org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 BinaryFeatureDomain (org.kie.kogito.explainability.model.domain.BinaryFeatureDomain)13 CurrencyFeatureDomain (org.kie.kogito.explainability.model.domain.CurrencyFeatureDomain)13 DurationFeatureDomain (org.kie.kogito.explainability.model.domain.DurationFeatureDomain)13 ObjectFeatureDomain (org.kie.kogito.explainability.model.domain.ObjectFeatureDomain)13 URIFeatureDomain (org.kie.kogito.explainability.model.domain.URIFeatureDomain)13 TimeFeatureDomain (org.kie.kogito.explainability.model.domain.TimeFeatureDomain)12 ArrayList (java.util.ArrayList)10 Output (org.kie.kogito.explainability.model.Output)8 Random (java.util.Random)7 PredictionFeatureDomain (org.kie.kogito.explainability.model.PredictionFeatureDomain)7 PredictionInput (org.kie.kogito.explainability.model.PredictionInput)7 Value (org.kie.kogito.explainability.model.Value)7