public class ScikitLearnClassifier
extends weka.classifiers.AbstractClassifier
implements weka.core.BatchPredictor, weka.core.CapabilitiesHandler
Modifier and Type | Class and Description |
---|---|
static class |
ScikitLearnClassifier.Learner
Holds info on the different learners available
|
Modifier and Type | Field and Description |
---|---|
static weka.core.Tag[] |
TAGS_LEARNER
The tags for the GUI drop-down for learner selection
|
Constructor and Description |
---|
ScikitLearnClassifier() |
Modifier and Type | Method and Description |
---|---|
void |
buildClassifier(weka.core.Instances data)
Build the classifier
|
double[] |
distributionForInstance(weka.core.Instance instance)
Return the predicted probabilities for the supplied instance
|
double[][] |
distributionsForInstances(weka.core.Instances insts)
Return the predicted probabilities for the supplied instances
|
java.lang.String |
getBatchSize() |
weka.core.Capabilities |
getCapabilities()
Get the capabilities of this learner
|
boolean |
getContinueOnSysErr()
Get whether to try and continue after seeing output on the sys error
stream.
|
boolean |
getDontFetchModelFromPython()
If true then don't retrieve the model from python.
|
weka.core.SelectedTag |
getLearner()
Get the scikit-learn scheme to use
|
java.lang.String |
getLearnerOpts()
Get the parameters to pass to the scikit-learn scheme
|
java.lang.String |
getPythonCommand()
Get the python command to use.
|
java.lang.String |
getPythonPath()
Get optional entries to prepend to the PATH so that python can execute
correctly.
|
java.lang.String |
getServerID()
Get an optional server name by which to identify the python server to use.
|
boolean |
getUseSupervisedNominalToBinary()
Get whether to use the supervised version of nominal to binary
|
java.lang.String |
globalInfo()
Global help info
|
boolean |
implementsMoreEfficientBatchPrediction()
Returns true, as we send entire test sets over to python for prediction
|
static void |
main(java.lang.String[] argv)
Main method for testing this class
|
void |
setBatchSize(java.lang.String size) |
void |
setContinueOnSysErr(boolean c)
Set whether to try and continue after seeing output on the sys error
stream.
|
void |
setDontFetchModelFromPython(boolean dontFetchModelFromPython)
If true then don't retrieve the model from python.
|
void |
setLearner(weka.core.SelectedTag learner)
Set the scikit-learn scheme to use
|
void |
setLearnerOpts(java.lang.String opts)
Set the parameters to pass to the scikit-learn scheme
|
void |
setPythonCommand(java.lang.String pyCommand)
Set the python command to use.
|
void |
setPythonPath(java.lang.String pythonPath)
Set optional entries to prepend to the PATH so that python can execute
correctly.
|
void |
setServerID(java.lang.String serverID)
Set an optional server name by which to identify the python server to use.
|
void |
setUseSupervisedNominalToBinary(boolean useSupervisedNominalToBinary)
Set whether to use the supervised version of nominal to binary
|
java.lang.String |
toString()
Get a textual description of this scheme
|
batchSizeTipText, classifyInstance, debugTipText, doNotCheckCapabilitiesTipText, forName, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getOptions, getRevision, listOptions, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces, setOptions
public static final weka.core.Tag[] TAGS_LEARNER
public java.lang.String globalInfo()
public weka.core.Capabilities getCapabilities()
getCapabilities
in interface weka.classifiers.Classifier
getCapabilities
in interface weka.core.CapabilitiesHandler
getCapabilities
in class weka.classifiers.AbstractClassifier
@OptionMetadata(displayName="Use supervised nominal to binary conversion", description="Use supervised nominal to binary conversion of nominal attributes.", commandLineParamName="S", commandLineParamSynopsis="-S", commandLineParamIsFlag=true, displayOrder=3) public boolean getUseSupervisedNominalToBinary()
public void setUseSupervisedNominalToBinary(boolean useSupervisedNominalToBinary)
useSupervisedNominalToBinary
- true if supervised nominal to binary is
to be used@OptionMetadata(displayName="Scikit-learn learner", description="Scikit-learn learner to use.\nAvailable learners:\nDecisionTreeClassifier, DecisionTreeRegressor, GaussianNB, MultinomialNB,BernoulliNB, LDA, QDA, LogisticRegression, LogisticRegressionCV,\nLinearRegression, ARDRegression, BayesianRidge, ElasticNet, Lars,\nLarsCV, Lasso, LassoCV, LassoLars, LassoLarsCV, LassoLarsIC, MLPClassifier, MLPRegressor, OrthogonalMatchingPursuit,\nOrthogonalMatchingPursuitCV, PassiveAggressiveClassifier, PassiveAggressiveRegressor, Perceptron, RANSACRegressor,\nRidge, RidgeClassifier, RidgeClassifierCV, RidgeCV, SGDClassifier,\nSGDRegressor,TheilSenRegressor, GaussianProcess, KernelRidge, KNeighborsClassifier, \nRadiusNeighborsClassifier, KNeighborsRegressor, RadiusNeighborsRegressor, SVC,\nLinearSVC, NuSVC, SVR, NuSVR, AdaBoostClassifier, AdaBoostRegressor,BaggingClassifier, BaggingRegressor,\nExtraTreeClassifier, ExtraTreeRegressor,GradientBoostingClassifier, GradientBoostingRegressor,\nRandomForestClassifier, RandomForestRegressor, XGBClassifier, XGBRegressor.\n(default = DecisionTreeClassifier)", commandLineParamName="learner", commandLineParamSynopsis="-learner <learner name>", displayOrder=1) public weka.core.SelectedTag getLearner()
public void setLearner(weka.core.SelectedTag learner)
learner
- the scikit-learn scheme to use@OptionMetadata(displayName="Learner parameters", description="learner parameters to use", displayOrder=2, commandLineParamName="parameters", commandLineParamSynopsis="-parameters <comma-separated list of name=value pairs>") public java.lang.String getLearnerOpts()
public void setLearnerOpts(java.lang.String opts)
opts
- the parameters to usepublic void setBatchSize(java.lang.String size)
setBatchSize
in interface weka.core.BatchPredictor
setBatchSize
in class weka.classifiers.AbstractClassifier
@OptionMetadata(displayName="Batch size", description="The preferred number of instances to transfer into python for prediction\n(if operatingin batch prediction mode). More or fewer instances than this will be accepted.", commandLineParamName="batch", commandLineParamSynopsis="-batch <batch size>", displayOrder=4) public java.lang.String getBatchSize()
getBatchSize
in interface weka.core.BatchPredictor
getBatchSize
in class weka.classifiers.AbstractClassifier
public boolean implementsMoreEfficientBatchPrediction()
implementsMoreEfficientBatchPrediction
in interface weka.core.BatchPredictor
implementsMoreEfficientBatchPrediction
in class weka.classifiers.AbstractClassifier
public void setContinueOnSysErr(boolean c)
c
- true if we should try to continue after seeing output on the sys
error stream@OptionMetadata(displayName="Try to continue after sys err output from script", description="Try to continue after sys err output from script.\nSome schemes report warnings to the system error stream.", displayOrder=5, commandLineParamName="continue-on-err", commandLineParamSynopsis="-continue-on-err", commandLineParamIsFlag=true) public boolean getContinueOnSysErr()
public void setDontFetchModelFromPython(boolean dontFetchModelFromPython)
dontFetchModelFromPython
- true to not fetch the model from python.@OptionMetadata(displayName="Don\'t retrieve model from python", description="Don\'t retrieve the model from python - speeds up cross-validation,\nbut prevents this classifier from being used after deserialization.\nSome models in python (e.g. large random forests) may exceed the maximum size for transfer\n(currently Integer.MAX_VALUE bytes)", displayOrder=6, commandLineParamName="dont-fetch-model", commandLineParamSynopsis="-dont-fetch-model", commandLineParamIsFlag=true) public boolean getDontFetchModelFromPython()
public void setPythonCommand(java.lang.String pyCommand)
pyCommand
- the path to the python executable (or empty
string/"default" to use python in the PATH)@OptionMetadata(displayName="Python command ", description="Path to python executable (\'default\' to use python in the PATH)", commandLineParamName="py-command", commandLineParamSynopsis="-py-command <path to python executable>", displayOrder=7) public java.lang.String getPythonCommand()
public void setPythonPath(java.lang.String pythonPath)
pythonPath
- additional entries to prepend to the PATH@OptionMetadata(displayName="Python path", description="Optional elements to prepend to the PATH so that python can execute correctly (\'default\' to use PATH as-is)", commandLineParamName="py-path", commandLineParamSynopsis="-py-path <path>", displayOrder=8) public java.lang.String getPythonPath()
public void setServerID(java.lang.String serverID)
serverID
- the name of the server to use (or none for no specific
server name).@OptionMetadata(displayName="Server name/ID", description="Optional name to identify this server, can be used to share a given server instance - default = \'none\' (i.e. no server name)", commandLineParamName="server-name", commandLineParamSynopsis="-server-name <server name | none>", displayOrder=9) public java.lang.String getServerID()
public void buildClassifier(weka.core.Instances data) throws java.lang.Exception
buildClassifier
in interface weka.classifiers.Classifier
data
- set of instances serving as training datajava.lang.Exception
- if a problem occurspublic double[] distributionForInstance(weka.core.Instance instance) throws java.lang.Exception
distributionForInstance
in interface weka.classifiers.Classifier
distributionForInstance
in class weka.classifiers.AbstractClassifier
instance
- the instance to be classifiedjava.lang.Exception
- if a problem occurspublic double[][] distributionsForInstances(weka.core.Instances insts) throws java.lang.Exception
distributionsForInstances
in interface weka.core.BatchPredictor
distributionsForInstances
in class weka.classifiers.AbstractClassifier
insts
- the instances to get predictions forjava.lang.Exception
- if a problem occurspublic java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] argv)
argv
- command line args