public class MLRClassifierImpl extends java.lang.Object implements BatchPredictor, OptionHandler, CapabilitiesHandler, RevisionHandler, java.io.Serializable
The class will attempt to install and load the MLR library if it is not already present in the user's R environment. Similarly, it will attempt to install and load specific base learners as required.
The classifier supports serialization by serializing to binary inside of R, retrieving the serialized classifier via the JRI native interface to R and then finally serializing the JRI REXP object to XML using XStream. The last step is required because JRI REXP objects do not implement Serializable.
Constructor and Description |
---|
MLRClassifierImpl() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
batchSizeTipText()
Returns the tip text for this property
|
void |
buildClassifier(Instances data)
Build the specified R learner on the incoming training data.
|
void |
closeREngine()
Close the R environment down.
|
java.lang.String |
debugTipText()
Returns the tip text for this property
|
double[] |
distributionForInstance(Instance inst)
Calculates the class membership probabilities for the given test instance.
|
double[][] |
distributionsForInstances(Instances insts)
Batch scoring method
|
java.lang.String |
dontReplaceMissingValuesTipText()
Returns the tip text for this property
|
java.lang.String |
getBatchSize()
Get the batch size for prediction (i.e.
|
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getDebug()
Get whether to output debugging info
|
boolean |
getDontReplaceMissingValues()
Get whether to turn off replacement of missing values in the data before it
is passed into R.
|
java.lang.String |
getLearnerParams()
Get the parameters for the R learner.
|
boolean |
getLogMessagesFromR()
Get whether to log info/warning messages from R to the console.
|
java.lang.String[] |
getOptions()
Gets the current settings of MLRClassifier.
|
java.lang.String |
getRevision()
Returns the revision string.
|
SelectedTag |
getRLearner()
Get the base R learner to use
|
int |
getSeed()
Gets the seed for the random number generations
|
java.lang.String |
globalInfo()
Global info for this wrapper classifier.
|
boolean |
implementsMoreEfficientBatchPrediction()
Returns true, as R schemes have to predict in batches and we push entire
test sets over into R
|
java.lang.String |
learnerParamsTipText()
Returns the tip text for this property
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
java.lang.String |
logMessagesFromRTipText()
Returns the tip text for this property
|
java.lang.String |
RLearnerTipText()
Returns the tip text for this property
|
java.lang.String |
seedTipText()
Returns the tip text for this property
|
void |
setBatchSize(java.lang.String size)
Set the batch size for prediction (i.e.
|
void |
setDebug(boolean d)
Set whether to output debugging info
|
void |
setDontReplaceMissingValues(boolean d)
Set whether to turn off replacement of missing values in the data before it
is passed into R.
|
void |
setLearnerParams(java.lang.String learnerParams)
Set the parameters for the R learner.
|
void |
setLogMessagesFromR(boolean l)
Set whether to log info/warning messages from R to the console.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setRLearner(SelectedTag learner)
Set the base R learner to use
|
void |
setSeed(int seed)
Set the seed for random number generation.
|
java.lang.String |
toString()
Returns the textual description of the R classifier.
|
public java.lang.String globalInfo()
public Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
public java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface OptionHandler
java.lang.Exception
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public java.lang.String debugTipText()
public void setDebug(boolean d)
d
- true if debugging info is to be outputpublic boolean getDebug()
public java.lang.String batchSizeTipText()
public java.lang.String getBatchSize()
getBatchSize
in interface BatchPredictor
public void setBatchSize(java.lang.String size)
setBatchSize
in interface BatchPredictor
public boolean implementsMoreEfficientBatchPrediction()
implementsMoreEfficientBatchPrediction
in interface BatchPredictor
public java.lang.String RLearnerTipText()
public void setRLearner(SelectedTag learner)
learner
- the learner to usepublic SelectedTag getRLearner()
public java.lang.String learnerParamsTipText()
public void setLearnerParams(java.lang.String learnerParams)
learnerParams
- the parameters (comma separated) to pass to the R
learner.public java.lang.String getLearnerParams()
public java.lang.String dontReplaceMissingValuesTipText()
public void setDontReplaceMissingValues(boolean d)
d
- true if missing values should not be replaced.public boolean getDontReplaceMissingValues()
public java.lang.String logMessagesFromRTipText()
public void setLogMessagesFromR(boolean l)
l
- true if info/warning messages should be logged to the console.public boolean getLogMessagesFromR()
public java.lang.String seedTipText()
public void setSeed(int seed)
seed
- the seedpublic int getSeed()
public void buildClassifier(Instances data) throws java.lang.Exception
data
- the training data to be used for generating the R model.java.lang.Exception
- if the classifier could not be built successfully.public double[][] distributionsForInstances(Instances insts) throws java.lang.Exception
distributionsForInstances
in interface BatchPredictor
insts
- the instances to push over to R and get predictions forjava.lang.Exception
- if a problem occurspublic double[] distributionForInstance(Instance inst) throws java.lang.Exception
inst
- the instance to be classifiedjava.lang.Exception
- if distribution can't be computed successfullypublic void closeREngine()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getRevision()
getRevision
in interface RevisionHandler