Search in sources :

Example 1 with NumericalFeatureDomain

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

the class ConversionUtilsTest method testToFeatureDomain_UnitRangeDouble.

@Test
void testToFeatureDomain_UnitRangeDouble() {
    FeatureDomain featureDomain = ConversionUtils.toFeatureDomain(new CounterfactualSearchDomainUnitValue("double", "double", true, new CounterfactualDomainRange(DoubleNode.valueOf(-273.15), DoubleNode.valueOf(Double.MAX_VALUE))));
    assertTrue(featureDomain instanceof NumericalFeatureDomain);
    NumericalFeatureDomain numericalFeatureDomain = (NumericalFeatureDomain) featureDomain;
    assertEquals(-273.15, numericalFeatureDomain.getLowerBound());
    assertEquals(Double.MAX_VALUE, numericalFeatureDomain.getUpperBound());
    assertNull(numericalFeatureDomain.getCategories());
}
Also used : CounterfactualDomainRange(org.kie.kogito.explainability.api.CounterfactualDomainRange) EmptyFeatureDomain(org.kie.kogito.explainability.model.domain.EmptyFeatureDomain) CategoricalFeatureDomain(org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) FeatureDomain(org.kie.kogito.explainability.model.domain.FeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) CounterfactualSearchDomainUnitValue(org.kie.kogito.explainability.api.CounterfactualSearchDomainUnitValue) Test(org.junit.jupiter.api.Test)

Example 2 with NumericalFeatureDomain

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

the class CounterfactualExplainerServiceHandlerTest method testGetPredictionWithFlatSearchDomainsNotFixed.

@Test
public void testGetPredictionWithFlatSearchDomainsNotFixed() {
    CounterfactualExplainabilityRequest request = new CounterfactualExplainabilityRequest(EXECUTION_ID, SERVICE_URL, MODEL_IDENTIFIER, COUNTERFACTUAL_ID, List.of(new NamedTypedValue("output1", new UnitValue("number", new IntNode(25)))), Collections.emptyList(), List.of(new CounterfactualSearchDomain("output1", new CounterfactualSearchDomainUnitValue("number", "number", false, new CounterfactualDomainRange(new IntNode(10), new IntNode(20))))), MAX_RUNNING_TIME_SECONDS);
    Prediction prediction = handler.getPrediction(request);
    assertTrue(prediction instanceof CounterfactualPrediction);
    CounterfactualPrediction counterfactualPrediction = (CounterfactualPrediction) prediction;
    assertEquals(1, counterfactualPrediction.getInput().getFeatures().size());
    Feature feature1 = counterfactualPrediction.getInput().getFeatures().get(0);
    assertTrue(feature1.getDomain() instanceof NumericalFeatureDomain);
    final NumericalFeatureDomain domain = (NumericalFeatureDomain) feature1.getDomain();
    assertEquals(10, domain.getLowerBound());
    assertEquals(20, domain.getUpperBound());
    assertEquals(counterfactualPrediction.getMaxRunningTimeSeconds(), request.getMaxRunningTimeSeconds());
}
Also used : CounterfactualExplainabilityRequest(org.kie.kogito.explainability.api.CounterfactualExplainabilityRequest) NamedTypedValue(org.kie.kogito.explainability.api.NamedTypedValue) IntNode(com.fasterxml.jackson.databind.node.IntNode) CounterfactualDomainRange(org.kie.kogito.explainability.api.CounterfactualDomainRange) Prediction(org.kie.kogito.explainability.model.Prediction) CounterfactualPrediction(org.kie.kogito.explainability.model.CounterfactualPrediction) UnitValue(org.kie.kogito.tracing.typedvalue.UnitValue) CounterfactualSearchDomainUnitValue(org.kie.kogito.explainability.api.CounterfactualSearchDomainUnitValue) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) CounterfactualSearchDomainUnitValue(org.kie.kogito.explainability.api.CounterfactualSearchDomainUnitValue) Feature(org.kie.kogito.explainability.model.Feature) CounterfactualSearchDomain(org.kie.kogito.explainability.api.CounterfactualSearchDomain) CounterfactualPrediction(org.kie.kogito.explainability.model.CounterfactualPrediction) Test(org.junit.jupiter.api.Test)

Example 3 with NumericalFeatureDomain

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

the class ConversionUtilsTest method testToFeatureDomain_UnitRangeInteger.

@Test
void testToFeatureDomain_UnitRangeInteger() {
    FeatureDomain featureDomain = ConversionUtils.toFeatureDomain(new CounterfactualSearchDomainUnitValue("int", "int", true, new CounterfactualDomainRange(IntNode.valueOf(18), IntNode.valueOf(65))));
    assertTrue(featureDomain instanceof NumericalFeatureDomain);
    NumericalFeatureDomain numericalFeatureDomain = (NumericalFeatureDomain) featureDomain;
    assertEquals(18.0, numericalFeatureDomain.getLowerBound());
    assertEquals(65.0, numericalFeatureDomain.getUpperBound());
    assertNull(numericalFeatureDomain.getCategories());
}
Also used : CounterfactualDomainRange(org.kie.kogito.explainability.api.CounterfactualDomainRange) EmptyFeatureDomain(org.kie.kogito.explainability.model.domain.EmptyFeatureDomain) CategoricalFeatureDomain(org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) FeatureDomain(org.kie.kogito.explainability.model.domain.FeatureDomain) NumericalFeatureDomain(org.kie.kogito.explainability.model.domain.NumericalFeatureDomain) CounterfactualSearchDomainUnitValue(org.kie.kogito.explainability.api.CounterfactualSearchDomainUnitValue) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 CounterfactualDomainRange (org.kie.kogito.explainability.api.CounterfactualDomainRange)3 CounterfactualSearchDomainUnitValue (org.kie.kogito.explainability.api.CounterfactualSearchDomainUnitValue)3 NumericalFeatureDomain (org.kie.kogito.explainability.model.domain.NumericalFeatureDomain)3 CategoricalFeatureDomain (org.kie.kogito.explainability.model.domain.CategoricalFeatureDomain)2 EmptyFeatureDomain (org.kie.kogito.explainability.model.domain.EmptyFeatureDomain)2 FeatureDomain (org.kie.kogito.explainability.model.domain.FeatureDomain)2 IntNode (com.fasterxml.jackson.databind.node.IntNode)1 CounterfactualExplainabilityRequest (org.kie.kogito.explainability.api.CounterfactualExplainabilityRequest)1 CounterfactualSearchDomain (org.kie.kogito.explainability.api.CounterfactualSearchDomain)1 NamedTypedValue (org.kie.kogito.explainability.api.NamedTypedValue)1 CounterfactualPrediction (org.kie.kogito.explainability.model.CounterfactualPrediction)1 Feature (org.kie.kogito.explainability.model.Feature)1 Prediction (org.kie.kogito.explainability.model.Prediction)1 UnitValue (org.kie.kogito.tracing.typedvalue.UnitValue)1