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());
}
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());
}
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());
}
Aggregations