-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ruivieira/RHOAIENG-7082
RHOAIENG-7082: Add SHAP support for KServe explainer
- Loading branch information
Showing
9 changed files
with
155 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,41 @@ | ||
package org.kie.trustyai; | ||
|
||
import io.quarkus.logging.Log; | ||
import io.quarkus.runtime.Quarkus; | ||
import io.quarkus.runtime.QuarkusApplication; | ||
import io.quarkus.runtime.annotations.QuarkusMain; | ||
import jakarta.inject.Inject; | ||
import picocli.CommandLine; | ||
import org.jboss.logging.Logger; | ||
|
||
import java.util.Arrays; | ||
|
||
@QuarkusMain | ||
public class ConfigCommand implements QuarkusApplication { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(ConfigCommand.class.getName()); | ||
|
||
@Inject | ||
CommandLineArgs cmdArgs; | ||
|
||
@Override | ||
public int run(String... args) { | ||
LOGGER.debug("Starting application..."); | ||
Log.info("Starting application..."); | ||
final CommandLine commandLine = new CommandLine(cmdArgs); | ||
|
||
Log.debug("Using command-line arguments: " + Arrays.toString(args)); | ||
try { | ||
commandLine.parseArgs(args); | ||
if (commandLine.isUsageHelpRequested()) { | ||
commandLine.usage(System.out); | ||
return 0; | ||
} | ||
|
||
|
||
LOGGER.debug("Configuration loaded successfully."); | ||
Log.info("Configuration loaded successfully."); | ||
} catch (CommandLine.ParameterException e) { | ||
LOGGER.error("Error parsing command line: " + e.getMessage()); | ||
Log.error("Error parsing command line: " + e.getMessage()); | ||
commandLine.usage(System.err); | ||
return 1; | ||
} | ||
|
||
Quarkus.waitForExit(); // Wait for Quarkus shutdown events | ||
LOGGER.debug("Quarkus is waiting for exit..."); | ||
Log.info("Quarkus is waiting for exit..."); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/org/kie/trustyai/StreamingGeneratorManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.kie.trustyai; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import org.kie.trustyai.explainability.local.shap.background.StreamingGenerator; | ||
import org.kie.trustyai.statistics.MultivariateOnlineEstimator; | ||
import org.kie.trustyai.statistics.distributions.gaussian.MultivariateGaussianParameters; | ||
import org.kie.trustyai.statistics.estimators.WelfordOnlineEstimator; | ||
|
||
@Singleton | ||
public class StreamingGeneratorManager { | ||
|
||
@Inject | ||
ConfigService configService; | ||
|
||
private StreamingGenerator streamingGenerator = null; | ||
|
||
public synchronized void initialize(int dimensions) { | ||
if (streamingGenerator == null && configService.getExplainerType() == ExplainerType.SHAP) { | ||
final MultivariateOnlineEstimator<MultivariateGaussianParameters> estimator = new WelfordOnlineEstimator(dimensions); | ||
streamingGenerator = new StreamingGenerator(dimensions, configService.getQueueSize(), configService.getDiversitySize(), estimator); | ||
} | ||
} | ||
|
||
public StreamingGenerator getStreamingGenerator() { | ||
return streamingGenerator; | ||
} | ||
|
||
} |
Oops, something went wrong.