|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.filters.Filter
wpi.filters.TimeGranularityFilter
Creates new attributes for the chosen time granularities. Each
new attribute specifies as an event set the periods of time during
which a granularity exists. For example if the base time unit of
a time line was days and the chosen granularity was a weekend the
new attribute weekend-granularity would have each Saturday and Sunday
noted as an event. Additionally, each granularity can be numbered
or unnumbered. That is, each weekend could be specified as an event
in the weekend-granularity attribute, or a new attribute can be
created for each weekend; weekend-granularity-1, weekend-granularity-2,
and so on. Each of these attributes would have at most 1 event for
each instance.
Hopefully one day this class will be extended to work with time lines
that use explicit dates but for now it will work with time lines
that use an integer format where the user knows the implicit units
of time it represents.
Valid filter-specific options are:
-N
Specifies granularities will be numbered.
-H
Specify the half granularity. That is the time line for each instance
is divided in half. Each instance will contain 2 half granularities.
-U
Specify a user defined granularity where a number of units on the
time line signifies the granularity. If the user chooses 10 then the
granularity is 10 units. The new attribute(s) will be named for this
value.
Field Summary | |
private static int |
debug
Specifies debug info level 0: no debug info 1: input to methods 2: and output from methods 3: and all sorts of stuff |
private java.util.Vector |
eventAttributeVector
list of time sequence attributes to find events in |
static java.lang.String |
HALF_GRANULARITY
The string for Half granularity attribute name. |
private static int |
HALF_INT
|
protected boolean |
halfGranularity
create half granularity? |
private double |
maxTime
For the numbered granularities we need to know the maximum time noted in the dataset. |
protected boolean |
numberedGranularities
numbered option |
private java.lang.String[] |
numberedUserAttributeStringArray
names for the attributes of the user numbered granularities |
static char |
SETBEGIN
|
static char |
SETDELIMITER
The delimiters to use for sets of events |
static char |
SETEND
|
static java.lang.String |
USER_GRANULARITY
The string to append for user defined granularity attribute name. |
private static int |
USER_INT
|
protected int |
userGranularitySize
size of user defined granularity |
Fields inherited from class weka.filters.Filter |
m_NewBatch |
Constructor Summary | |
TimeGranularityFilter()
|
Method Summary | |
boolean |
batchFinished()
Signifies that this batch of input to the filter is finished. |
private void |
fillNumberedUserAttributeStringArray()
Creates a list of attribute names for the user specified granularity when the numbered granularities option is set. |
protected void |
findEventAttributes()
Finds the event attributes in the input format. |
private java.lang.String[] |
getGranularityEvents(weka.core.Instance instance,
int granularityType)
Finds the granularities for the instance specified. |
boolean |
getHalfGranularity()
Returns if the filter should create the half granularity. |
boolean |
getNumberedGranularities()
Returns if the filter should create numbered granularities. |
java.lang.String[] |
getOptions()
Gets the current settings of the filter. |
int |
getUserGranularitySize()
Returns the user granularity size |
java.lang.String |
globalInfo()
Returns a string describing this filter. |
java.lang.String |
halfGranularityTipText()
|
boolean |
input(weka.core.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. |
java.lang.String |
numberedGranularitiesTipText()
|
void |
setHalfGranularity(boolean b)
Sets if the filter should create the half granularity. |
boolean |
setInputFormat(weka.core.Instances instanceInfo)
Sets the format of the input instances. |
void |
setNumberedGranularities(boolean b)
Sets if the filter should create numbered granularities. |
void |
setOptions(java.lang.String[] options)
Parses a list of options for this object. |
private void |
setOutputFormat()
Sets the output format. |
void |
setUserGranularitySize(int n)
Sets the size of the user defined granularity in terms of time line units. |
void |
setUserGranularitySize(java.lang.String n)
Sets the size of the user defined granularity in terms of time line units. |
java.lang.String |
userGranularitySizeTipText()
|
Methods inherited from class weka.filters.Filter |
batchFilterFile, bufferInput, copyStringValues, copyStringValues, filterFile, flushInput, getInputFormat, getInputStringIndex, getOutputFormat, getOutputStringIndex, getStringIndices, inputFormat, isOutputFormatDefined, numPendingOutput, output, outputFormat, outputFormatPeek, outputPeek, push, resetQueue, setOutputFormat, useFilter |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.lang.String HALF_GRANULARITY
public static java.lang.String USER_GRANULARITY
private static final int HALF_INT
private static final int USER_INT
public static char SETDELIMITER
public static char SETBEGIN
public static char SETEND
private double maxTime
private java.util.Vector eventAttributeVector
protected boolean numberedGranularities
protected boolean halfGranularity
protected int userGranularitySize
private java.lang.String[] numberedUserAttributeStringArray
private static final int debug
Constructor Detail |
public TimeGranularityFilter()
Method Detail |
public void setUserGranularitySize(java.lang.String n)
n
- the number of unitspublic void setUserGranularitySize(int n)
n
- the number of unitspublic int getUserGranularitySize()
public java.lang.String userGranularitySizeTipText()
public void setHalfGranularity(boolean b)
b
- true to define half granularity, false otherwisepublic boolean getHalfGranularity()
public java.lang.String halfGranularityTipText()
public void setNumberedGranularities(boolean b)
b
- true to create numbered granularities, false otherwisepublic boolean getNumberedGranularities()
public java.lang.String numberedGranularitiesTipText()
private java.lang.String[] getGranularityEvents(weka.core.Instance instance, int granularityType)
public boolean setInputFormat(weka.core.Instances instanceInfo) throws java.lang.Exception
instanceInfo
- an Instances object containing the input instance
structure (any values of instances contained in the object are
ignored) but in addition to the structure, this filter does require
to know the number of instances in the input data set.
java.lang.Exception
- if the format couldn't be set successfullyprivate void setOutputFormat()
protected void findEventAttributes()
private void fillNumberedUserAttributeStringArray()
public boolean input(weka.core.Instance instance)
instance
- the input instance
java.lang.IllegalStateException
- if no input format has been defined.public boolean batchFinished()
java.lang.IllegalStateException
- if no input structure has been defined.public java.lang.String globalInfo()
public java.util.Enumeration listOptions()
listOptions
in interface weka.core.OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface weka.core.OptionHandler
options
- the list of options as an array of strings
- attributes java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface weka.core.OptionHandler
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 |