Class LIMETextCLI
java.lang.Object
org.tribuo.classification.explanations.lime.LIMETextCLI
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.command.CommandGroup
A CLI for interacting with
LIMEText
. Uses a simple tokenisation and text extraction pipeline.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Command line options. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionExplains a text classification.featureInfo
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String featureName) Shows information on a particular feature.org.jline.reader.Completer[]
Completers for filenames.generatesProbabilities
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci) Does the model generate probabilities.getName()
Loads a model in from disk.static void
Runs a LIMETextCLI.minCount
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int minCount) Shows the number of features that occurred more than minCount times.modelDescription
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci) Shows the model description.numFeatures
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci) Shows the number of features.Makes a prediction using the loaded model.setNumFeatures
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int newNumFeatures) Sets the number of features LIME should use in an explanation.setNumSamples
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int newNumSamples) Sets the number of samples to use in LIME.showLabelStats
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci) Shows the output statistics.void
Start the command shelltopFeatures
(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int numFeatures) Shows the top features of the loaded model.
-
Constructor Details
-
LIMETextCLI
public LIMETextCLI()Constructs a LIME CLI.
-
-
Method Details
-
getName
- Specified by:
getName
in interfacecom.oracle.labs.mlrg.olcut.command.CommandGroup
-
getDescription
- Specified by:
getDescription
in interfacecom.oracle.labs.mlrg.olcut.command.CommandGroup
-
fileCompleter
public org.jline.reader.Completer[] fileCompleter()Completers for filenames.- Returns:
- The filename completers.
-
startShell
public void startShell()Start the command shell -
loadModel
@Command(usage="<filename> - Load a model from disk.", completers="fileCompleter") public String loadModel(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, File path) Loads a model in from disk.- Parameters:
ci
- The command interpreter.path
- The path to load the model from.- Returns:
- A status message.
-
generatesProbabilities
@Command(usage="Does the model generate probabilities") public String generatesProbabilities(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci) Does the model generate probabilities.- Parameters:
ci
- The command interpreter.- Returns:
- True if the model generates probabilities.
-
modelDescription
@Command(usage="Shows the model description") public String modelDescription(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci) Shows the model description.- Parameters:
ci
- The command interpreter.- Returns:
- The model description.
-
featureInfo
@Command(usage="Shows the information on a particular feature") public String featureInfo(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String featureName) Shows information on a particular feature.- Parameters:
ci
- The command interpreter.featureName
- The feature to show.- Returns:
- Feature information.
-
topFeatures
@Command(usage="<int> - Shows the top N features in the model") public String topFeatures(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int numFeatures) Shows the top features of the loaded model.- Parameters:
ci
- The command interpeter.numFeatures
- The number of features to show.- Returns:
- The top features of the model.
-
numFeatures
@Command(usage="Shows the number of features in the model") public String numFeatures(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci) Shows the number of features.- Parameters:
ci
- The command interpreter.- Returns:
- The number of features in the model.
-
minCount
@Command(usage="<min count> - Shows the number of features that occurred more than min count times.") public String minCount(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int minCount) Shows the number of features that occurred more than minCount times.- Parameters:
ci
- The command interpreter.minCount
- The minimum feature occurrence.- Returns:
- The number of features with more than minCount occurrences.
-
showLabelStats
@Command(usage="Shows the output statistics") public String showLabelStats(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci) Shows the output statistics.- Parameters:
ci
- The command interpreter.- Returns:
- The output statistics.
-
setNumSamples
@Command(usage="Sets the number of samples to use in LIME") public String setNumSamples(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int newNumSamples) Sets the number of samples to use in LIME.- Parameters:
ci
- The command interpreter.newNumSamples
- The number of samples to use in LIME.- Returns:
- A status message.
-
explain
@Command(usage="Explain a text classification") public String explain(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String[] tokens) Explains a text classification.- Parameters:
ci
- The command interpreter.tokens
- A space separated token stream.- Returns:
- An explanation.
-
setNumFeatures
@Command(usage="Sets the number of features LIME should use in an explanation") public String setNumFeatures(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, int newNumFeatures) Sets the number of features LIME should use in an explanation.- Parameters:
ci
- The command interpreter.newNumFeatures
- The number of features.- Returns:
- A status message.
-
predict
@Command(usage="Make a prediction") public String predict(com.oracle.labs.mlrg.olcut.command.CommandInterpreter ci, String[] tokens) Makes a prediction using the loaded model.- Parameters:
ci
- The command interpreter.tokens
- A space separated token stream.- Returns:
- The prediction.
-
main
Runs a LIMETextCLI.- Parameters:
args
- The CLI arguments.
-