public abstract class AbstractOutput extends java.lang.Object implements java.io.Serializable, OptionHandler
Classifier classifier = ... // trained classifier Instances testset = ... // the test set to output the predictions for StringBuffer buffer = ... // the string buffer to add the output to AbstractOutput output = new FunkyOutput(); output.setHeader(...); output.printClassifications(classifier, testset);Basic use with a classifier and a data source:
Classifier classifier = ... // trained classifier DataSource testset = ... // the data source to obtain the test set from to output the predictions for StringBuffer buffer = ... // the string buffer to add the output to AbstractOutput output = new FunkyOutput(); output.setHeader(...); output.printClassifications(classifier, testset);In order to make the output generation easily integrate into GUI components, one can output the header, classifications and footer separately:
Classifier classifier = ... // trained classifier Instances testset = ... // the test set to output the predictions for StringBuffer buffer = ... // the string buffer to add the output to AbstractOutput output = new FunkyOutput(); output.setHeader(...); // print the header output.printHeader(); // print the classifications one-by-one for (int i = 0; i < testset.numInstances(); i++) { output.printClassification(classifier, testset.instance(i), i); // output progress information if ((i+1) % 100 == 0) System.out.println((i+1) + "/" + testset.numInstances()); } // print the footer output.printFooter();
Constructor and Description |
---|
AbstractOutput()
Initializes the output class.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
attributesTipText()
Returns the tip text for this property.
|
static AbstractOutput |
fromCommandline(java.lang.String cmdline)
Returns a fully configured object from the given commandline.
|
boolean |
generatesOutput()
Returns whether regular output is generated or not.
|
java.lang.String |
getAttributes()
Returns the range of attributes to output.
|
java.lang.StringBuffer |
getBuffer()
Returns the current buffer.
|
int |
getDefaultNumDecimals()
Returns the default number of digits to output after the decimal point.
|
abstract java.lang.String |
getDisplay()
Returns a short display text, to be used in comboboxes.
|
Instances |
getHeader()
Returns the header of the dataset.
|
int |
getNumDecimals()
Returns the number of digits to output after the decimal point.
|
java.lang.String[] |
getOptions()
Gets the current option settings for the OptionHandler.
|
boolean |
getOutputDistribution()
Returns whether to output the class distribution as well.
|
java.io.File |
getOutputFile()
Returns the output file to write to.
|
boolean |
getSuppressOutput()
Returns whether to the regular output is suppressed in case the output is
stored in a file.
|
abstract java.lang.String |
globalInfo()
Returns a string describing the output generator.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration of all the available options..
|
java.lang.String |
numDecimalsTipText()
Returns the tip text for this property.
|
java.lang.String |
outputDistributionTipText()
Returns the tip text for this property.
|
java.lang.String |
outputFileTipText()
Returns the tip text for this property.
|
void |
print(Classifier classifier,
ConverterUtils.DataSource testset)
Prints the header, classifications and footer to the buffer.
|
void |
print(Classifier classifier,
Instances testset)
Prints the header, classifications and footer to the buffer.
|
void |
printClassification(Classifier classifier,
Instance inst,
int index)
Prints the classification to the buffer.
|
void |
printClassification(double[] dist,
Instance inst,
int index)
Prints the classification to the buffer.
|
void |
printClassifications(Classifier classifier,
ConverterUtils.DataSource testset)
Prints the classifications to the buffer.
|
void |
printClassifications(Classifier classifier,
Instances testset)
Prints the classifications to the buffer.
|
void |
printFooter()
Prints the footer to the buffer.
|
void |
printHeader()
Prints the header to the buffer.
|
void |
setAttributes(java.lang.String value)
Sets the range of attributes to output.
|
void |
setBuffer(java.lang.StringBuffer value)
Sets the buffer to use.
|
void |
setHeader(Instances value)
Sets the header of the dataset.
|
void |
setNumDecimals(int value)
Sets the number of digits to output after the decimal point.
|
void |
setOptions(java.lang.String[] options)
Sets the OptionHandler's options using the given list.
|
void |
setOutputDistribution(boolean value)
Sets whether to output the class distribution or not.
|
void |
setOutputFile(java.io.File value)
Sets the output file to write to.
|
void |
setSuppressOutput(boolean value)
Sets whether to the regular output is suppressed in case the output is
stored in a file.
|
java.lang.String |
suppressOutputTipText()
Returns the tip text for this property.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
makeCopy
public abstract java.lang.String globalInfo()
public abstract java.lang.String getDisplay()
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
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public void setHeader(Instances value)
value
- the headerpublic Instances getHeader()
public void setBuffer(java.lang.StringBuffer value)
value
- the bufferpublic java.lang.StringBuffer getBuffer()
public void setAttributes(java.lang.String value)
value
- the rangepublic java.lang.String getAttributes()
public java.lang.String attributesTipText()
public void setOutputDistribution(boolean value)
value
- true if the class distribution is to be output as wellpublic boolean getOutputDistribution()
public java.lang.String outputDistributionTipText()
public int getDefaultNumDecimals()
public void setNumDecimals(int value)
value
- the number of digitspublic int getNumDecimals()
public java.lang.String numDecimalsTipText()
public void setOutputFile(java.io.File value)
value
- the file to write to or a directorypublic java.io.File getOutputFile()
public java.lang.String outputFileTipText()
public void setSuppressOutput(boolean value)
value
- true if the regular output is to be suppressedpublic boolean getSuppressOutput()
public java.lang.String suppressOutputTipText()
public boolean generatesOutput()
public void printHeader()
public void printClassification(Classifier classifier, Instance inst, int index) throws java.lang.Exception
classifier
- the classifier to use for printing the classificationinst
- the instance to printindex
- the index of the instancejava.lang.Exception
- if check fails or error occurs during printing of
classificationpublic void printClassification(double[] dist, Instance inst, int index) throws java.lang.Exception
dist
- the distribution from classifier for the supplied instanceinst
- the instance to printindex
- the index of the instancejava.lang.Exception
- if check fails or error occurs during printing of
classificationpublic void printClassifications(Classifier classifier, ConverterUtils.DataSource testset) throws java.lang.Exception
classifier
- the classifier to use for printing the classificationstestset
- the data source to obtain the test instances fromjava.lang.Exception
- if check fails or error occurs during printing of
classificationspublic void printClassifications(Classifier classifier, Instances testset) throws java.lang.Exception
classifier
- the classifier to use for printing the classificationstestset
- the test instancesjava.lang.Exception
- if check fails or error occurs during printing of
classificationspublic void printFooter() throws java.lang.Exception
java.lang.Exception
- if check failspublic void print(Classifier classifier, ConverterUtils.DataSource testset) throws java.lang.Exception
classifier
- the classifier to use for printing the classificationstestset
- the data source to obtain the test instances fromjava.lang.Exception
- if check fails or error occurs during printing of
classificationspublic void print(Classifier classifier, Instances testset) throws java.lang.Exception
classifier
- the classifier to use for printing the classificationstestset
- the test instancesjava.lang.Exception
- if check fails or error occurs during printing of
classificationspublic static AbstractOutput fromCommandline(java.lang.String cmdline)
cmdline
- the commandline to turn into an object