Search in sources :

Example 1 with SimpleBigDecimalScore

use of org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore in project kogito-apps by kiegroup.

the class LimeImpactScoreCalculatorTest method testNonZeroScore.

@Test
void testNonZeroScore() throws ExecutionException, InterruptedException, TimeoutException {
    PredictionProvider model = TestUtils.getDummyTextClassifier();
    LimeImpactScoreCalculator scoreCalculator = new LimeImpactScoreCalculator();
    LimeConfig config = new LimeConfig();
    List<Feature> features = List.of(FeatureFactory.newFulltextFeature("text", "money so they say is the root of all evil today"));
    PredictionInput input = new PredictionInput(features);
    List<PredictionOutput> predictionOutputs = model.predictAsync(List.of(input)).get(Config.DEFAULT_ASYNC_TIMEOUT, Config.DEFAULT_ASYNC_TIMEUNIT);
    assertThat(predictionOutputs).isNotNull();
    assertThat(predictionOutputs.size()).isEqualTo(1);
    PredictionOutput output = predictionOutputs.get(0);
    Prediction prediction = new SimplePrediction(input, output);
    List<Prediction> predictions = List.of(prediction);
    List<LimeConfigEntity> entities = LimeConfigEntityFactory.createEncodingEntities(config);
    LimeConfigSolution solution = new LimeConfigSolution(config, predictions, entities, model);
    SimpleBigDecimalScore score = scoreCalculator.calculateScore(solution);
    assertThat(score).isNotNull();
    assertThat(score.getScore()).isNotNull().isNotEqualTo(BigDecimal.valueOf(0));
}
Also used : SimplePrediction(org.kie.kogito.explainability.model.SimplePrediction) PredictionInput(org.kie.kogito.explainability.model.PredictionInput) SimplePrediction(org.kie.kogito.explainability.model.SimplePrediction) Prediction(org.kie.kogito.explainability.model.Prediction) PredictionProvider(org.kie.kogito.explainability.model.PredictionProvider) Feature(org.kie.kogito.explainability.model.Feature) LimeConfig(org.kie.kogito.explainability.local.lime.LimeConfig) PredictionOutput(org.kie.kogito.explainability.model.PredictionOutput) SimpleBigDecimalScore(org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore) Test(org.junit.jupiter.api.Test)

Example 2 with SimpleBigDecimalScore

use of org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore in project kogito-apps by kiegroup.

the class LimeStabilityScoreCalculatorTest method testScoreWithEmptyPredictions.

@Test
void testScoreWithEmptyPredictions() {
    LimeStabilityScoreCalculator scoreCalculator = new LimeStabilityScoreCalculator();
    LimeConfig config = new LimeConfig();
    List<Prediction> predictions = Collections.emptyList();
    List<LimeConfigEntity> entities = Collections.emptyList();
    PredictionProvider model = TestUtils.getDummyTextClassifier();
    LimeConfigSolution solution = new LimeConfigSolution(config, predictions, entities, model);
    SimpleBigDecimalScore score = scoreCalculator.calculateScore(solution);
    assertThat(score).isNotNull();
    assertThat(score.getScore()).isNotNull();
    assertThat(score.getScore()).isEqualTo(BigDecimal.valueOf(0));
}
Also used : Prediction(org.kie.kogito.explainability.model.Prediction) SimpleBigDecimalScore(org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore) PredictionProvider(org.kie.kogito.explainability.model.PredictionProvider) LimeConfig(org.kie.kogito.explainability.local.lime.LimeConfig) Test(org.junit.jupiter.api.Test)

Example 3 with SimpleBigDecimalScore

use of org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore in project kogito-apps by kiegroup.

the class LimeImpactScoreCalculatorTest method testScoreWithEmptyPredictions.

@Test
void testScoreWithEmptyPredictions() {
    LimeImpactScoreCalculator scoreCalculator = new LimeImpactScoreCalculator();
    LimeConfig config = new LimeConfig();
    List<Prediction> predictions = Collections.emptyList();
    List<LimeConfigEntity> entities = Collections.emptyList();
    PredictionProvider model = TestUtils.getDummyTextClassifier();
    LimeConfigSolution solution = new LimeConfigSolution(config, predictions, entities, model);
    SimpleBigDecimalScore score = scoreCalculator.calculateScore(solution);
    assertThat(score).isNotNull();
    assertThat(score.getScore()).isNotNull().isEqualTo(BigDecimal.valueOf(0));
}
Also used : SimplePrediction(org.kie.kogito.explainability.model.SimplePrediction) Prediction(org.kie.kogito.explainability.model.Prediction) SimpleBigDecimalScore(org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore) PredictionProvider(org.kie.kogito.explainability.model.PredictionProvider) LimeConfig(org.kie.kogito.explainability.local.lime.LimeConfig) Test(org.junit.jupiter.api.Test)

Example 4 with SimpleBigDecimalScore

use of org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore in project kogito-apps by kiegroup.

the class LimeCombinedScoreCalculatorTest method testNonZeroScore.

@Test
void testNonZeroScore() throws ExecutionException, InterruptedException, TimeoutException {
    PredictionProvider model = TestUtils.getDummyTextClassifier();
    LimeCombinedScoreCalculator scoreCalculator = new LimeCombinedScoreCalculator();
    LimeConfig config = new LimeConfig();
    List<Feature> features = List.of(FeatureFactory.newFulltextFeature("text", "money so they say is the root of all evil today"));
    PredictionInput input = new PredictionInput(features);
    List<PredictionOutput> predictionOutputs = model.predictAsync(List.of(input)).get(Config.DEFAULT_ASYNC_TIMEOUT, Config.DEFAULT_ASYNC_TIMEUNIT);
    assertThat(predictionOutputs).isNotNull();
    assertThat(predictionOutputs.size()).isEqualTo(1);
    PredictionOutput output = predictionOutputs.get(0);
    Prediction prediction = new SimplePrediction(input, output);
    List<Prediction> predictions = List.of(prediction);
    List<LimeConfigEntity> entities = LimeConfigEntityFactory.createEncodingEntities(config);
    LimeConfigSolution solution = new LimeConfigSolution(config, predictions, entities, model);
    SimpleBigDecimalScore score = scoreCalculator.calculateScore(solution);
    assertThat(score).isNotNull();
    assertThat(score.getScore()).isNotNull().isNotEqualTo(BigDecimal.valueOf(0));
}
Also used : SimplePrediction(org.kie.kogito.explainability.model.SimplePrediction) PredictionInput(org.kie.kogito.explainability.model.PredictionInput) SimplePrediction(org.kie.kogito.explainability.model.SimplePrediction) Prediction(org.kie.kogito.explainability.model.Prediction) PredictionProvider(org.kie.kogito.explainability.model.PredictionProvider) Feature(org.kie.kogito.explainability.model.Feature) LimeConfig(org.kie.kogito.explainability.local.lime.LimeConfig) PredictionOutput(org.kie.kogito.explainability.model.PredictionOutput) SimpleBigDecimalScore(org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore) Test(org.junit.jupiter.api.Test)

Example 5 with SimpleBigDecimalScore

use of org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore in project kogito-apps by kiegroup.

the class LimeCombinedScoreCalculatorTest method testScoreWithEmptyPredictions.

@Test
void testScoreWithEmptyPredictions() {
    LimeCombinedScoreCalculator scoreCalculator = new LimeCombinedScoreCalculator();
    LimeConfig config = new LimeConfig();
    List<Prediction> predictions = Collections.emptyList();
    List<LimeConfigEntity> entities = Collections.emptyList();
    PredictionProvider model = TestUtils.getDummyTextClassifier();
    LimeConfigSolution solution = new LimeConfigSolution(config, predictions, entities, model);
    SimpleBigDecimalScore score = scoreCalculator.calculateScore(solution);
    assertThat(score).isNotNull();
    assertThat(score.getScore()).isNotNull().isEqualTo(BigDecimal.valueOf(0));
}
Also used : SimplePrediction(org.kie.kogito.explainability.model.SimplePrediction) Prediction(org.kie.kogito.explainability.model.Prediction) SimpleBigDecimalScore(org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore) PredictionProvider(org.kie.kogito.explainability.model.PredictionProvider) LimeConfig(org.kie.kogito.explainability.local.lime.LimeConfig) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)5 LimeConfig (org.kie.kogito.explainability.local.lime.LimeConfig)5 Prediction (org.kie.kogito.explainability.model.Prediction)5 PredictionProvider (org.kie.kogito.explainability.model.PredictionProvider)5 SimpleBigDecimalScore (org.optaplanner.core.api.score.buildin.simplebigdecimal.SimpleBigDecimalScore)5 SimplePrediction (org.kie.kogito.explainability.model.SimplePrediction)4 Feature (org.kie.kogito.explainability.model.Feature)2 PredictionInput (org.kie.kogito.explainability.model.PredictionInput)2 PredictionOutput (org.kie.kogito.explainability.model.PredictionOutput)2