|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.filters.Filter
weka.filters.supervised.attribute.ClassOrder
A filter that sorts the order of classes so that the class values are no longer of in the order of that in the header file after filtered. The values of the class will be in the order specified by the user -- it could be either in ascending/descending order by the class frequency or in random order.
The format of the header is thus not changed in this filter
(although it still uses setInputFormat()
), but
the class value of each instance is converted to sorted
values within the same range. The value can also be converted back
using originalValue(double value)
procedure.
Field Summary | |
static int |
FREQ_ASCEND
The class values are sorted in ascending order based on their frequencies |
static int |
FREQ_DESCEND
The class values are sorted in descending order based on their frequencies |
static int |
RANDOM
The class values are sorted in random order |
Constructor Summary | |
ClassOrder()
|
Method Summary | |
boolean |
batchFinished()
Signify that this batch of input to the filter is finished. |
java.lang.String |
classOrderTipText()
Returns the tip text for this property |
double[] |
distributionsByOriginalIndex(double[] before)
Convert the given class distribution back to the distributions with the original internal class index |
double[] |
getClassCounts()
Get the class distribution of the sorted class values. |
int |
getClassOrder()
Get the wanted class order |
java.lang.String[] |
getOptions()
Gets the current settings of the filter. |
long |
getSeed()
Get the current randomization seed |
java.lang.String |
globalInfo()
Returns a string describing this filter |
boolean |
input(Instance instance)
Input an instance for filtering. |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options. |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
double |
originalValue(double value)
Return the original internal class value given the randomized class value, i.e. |
java.lang.String |
seedTipText()
Returns the tip text for this property |
void |
setClassOrder(int order)
Set the wanted class order |
boolean |
setInputFormat(Instances instanceInfo)
Sets the format of the input instances. |
void |
setOptions(java.lang.String[] options)
Parses a given list of options controlling the behaviour of this object. |
void |
setSeed(long seed)
Set randomization seed |
Methods inherited from class weka.filters.Filter |
batchFilterFile, filterFile, getOutputFormat, inputFormat, isOutputFormatDefined, numPendingOutput, output, outputFormat, outputPeek, useFilter |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FREQ_ASCEND
public static final int FREQ_DESCEND
public static final int RANDOM
Constructor Detail |
public ClassOrder()
Method Detail |
public java.lang.String globalInfo()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-R
-C
Specify the seed of randomization used to randomize the class order
(default: 1)
Specify the class order to be sorted, could be 0: ascending, 1: descending
and 2: random(default: 0)
setOptions
in interface OptionHandler
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supported
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public java.lang.String seedTipText()
public long getSeed()
public void setSeed(long seed)
seed
- the set seedpublic java.lang.String classOrderTipText()
public int getClassOrder()
public void setClassOrder(int order)
order
- the class orderpublic boolean setInputFormat(Instances instanceInfo) throws java.lang.Exception
setInputFormat
in class Filter
instanceInfo
- an Instances object containing the input instance
structure (any instances contained in the object are ignored - only the
structure is required).
java.lang.Exception
- if the inputFormat can't be set successfullypublic boolean input(Instance instance)
input
in class Filter
instance
- the input instance
java.lang.IllegalStateException
- if no input format has been defined.public boolean batchFinished() throws java.lang.Exception
batchFinished
in class Filter
java.lang.NullPointerException
- if no input structure has been defined,
java.lang.Exception
- if there was a problem finishing the batch.public double[] getClassCounts()
public double[] distributionsByOriginalIndex(double[] before)
before
- the given class distribution
public double originalValue(double value) throws java.lang.Exception
value
- the given value
if
- the coverter table is not set yet
java.lang.Exception
public static void main(java.lang.String[] argv)
argv
- should contain arguments to the filter: use -h for help
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |