use of org.kie.kogito.explainability.model.Feature in project kogito-apps by kiegroup.
the class DoubleEntityTest method distanceUnscaled.
@Test
void distanceUnscaled() {
final FeatureDomain featureDomain = NumericalFeatureDomain.create(0.0, 40.0);
final Feature doubleFeature = FeatureFactory.newNumericalFeature("feature-double", 20.0, featureDomain);
DoubleEntity entity = (DoubleEntity) CounterfactualEntityFactory.from(doubleFeature);
entity.proposedValue = 30.0;
assertEquals(10.0, entity.distance());
}
use of org.kie.kogito.explainability.model.Feature in project kogito-apps by kiegroup.
the class IntegerEntityTest method distanceUnscaled.
@Test
void distanceUnscaled() {
final FeatureDomain featureDomain = NumericalFeatureDomain.create(0, 100);
final Feature integerFeature = FeatureFactory.newNumericalFeature("feature-integer", 20, featureDomain);
IntegerEntity entity = (IntegerEntity) CounterfactualEntityFactory.from(integerFeature);
entity.proposedValue = 40;
assertEquals(20.0, entity.distance());
}
use of org.kie.kogito.explainability.model.Feature in project kogito-apps by kiegroup.
the class LongEntityTest method distanceUnscaled.
@Test
void distanceUnscaled() {
final FeatureDomain featureDomain = NumericalFeatureDomain.create(0, 100);
final Feature feature = FeatureFactory.newNumericalFeature("feature-long", 20L, featureDomain);
LongEntity entity = (LongEntity) CounterfactualEntityFactory.from(feature);
entity.proposedValue = 40L;
assertEquals(20.0, entity.distance());
}
use of org.kie.kogito.explainability.model.Feature in project kogito-apps by kiegroup.
the class DatasetEncoderTest method testDatasetEncodingWithBooleanData.
@Test
void testDatasetEncodingWithBooleanData() {
List<PredictionInput> perturbedInputs = new LinkedList<>();
for (int i = 0; i < 10; i++) {
List<Feature> inputFeatures = new LinkedList<>();
for (int j = 0; j < 3; j++) {
inputFeatures.add(TestUtils.getMockedFeature(Type.BOOLEAN, new Value(j % 2 == 0)));
}
perturbedInputs.add(new PredictionInput(inputFeatures));
}
List<Feature> features = new LinkedList<>();
for (int i = 0; i < 3; i++) {
features.add(TestUtils.getMockedFeature(Type.BOOLEAN, new Value(i % 2 == 0)));
}
PredictionInput originalInput = new PredictionInput(features);
assertEncode(perturbedInputs, originalInput);
}
use of org.kie.kogito.explainability.model.Feature in project kogito-apps by kiegroup.
the class DatasetEncoderTest method testEmptyDatasetEncoding.
@Test
void testEmptyDatasetEncoding() {
List<PredictionInput> inputs = new LinkedList<>();
List<Output> outputs = new LinkedList<>();
List<Feature> features = new LinkedList<>();
Output originalOutput = new Output("foo", Type.NUMBER, new Value(1), 1d);
EncodingParams params = new EncodingParams(1, 0.1);
DatasetEncoder datasetEncoder = new DatasetEncoder(inputs, outputs, features, originalOutput, params);
Collection<Pair<double[], Double>> trainingSet = datasetEncoder.getEncodedTrainingSet();
assertNotNull(trainingSet);
assertTrue(trainingSet.isEmpty());
}
Aggregations