|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.rapidminer.operator.Operator
public abstract class Operator
An operator accepts an array of input objects and generates an array of output objects that can be processed by other operators. Both must implement the IOObject interface. This is the superclass which must be extended by all RapidMiner operators. Please refer to the RapidMiner tutorial for a detailed description how to implement your operator.
As default, operators consume their input by using it. This is often a useful
behavior especially in complex processes. For example, a learning operator
consumes an example set to produce a model and so does a cross validation to
produce a performance value of the learning method. To receive the input
IOObject of a certain class simply use getInput(Class class).
This method delivers the first object of the desired class which is in the
input of this operator. The delivered object is consumed afterwards and thus
is removed from input. If the operator alters this object, it should return
the altered object as output again. Therefore, you have to add the object to
the output array which is delivered by the apply() method of the
operator. You also have to declare it in getOutputClasses(). All
input objects which are not used by your operator will be automatically
passed to the next operators.
In some cases it would be useful if the user can define if the input object
should be consumed or not. For example, a validation chain like cross
validation should estimate the performance but should also be able to return
the example set which is then used to learn the overall model. Operators can
change the default behavior for input consumation and a parameter will be
automatically defined and queried. The default behavior is defined in the
method getInputDescription(Class cls) and should be overriden in
these cases. Please note that input objects with a changed input description
must not be defined in getOutputClasses() and must not be returned
at the end of apply. Both is automatically done with respect to the value of
the automatically created parameter. Please refer to the Javadoc comments of
this method for further explanations.
OperatorChain| Constructor Summary | |
|---|---|
Operator(OperatorDescription description)
Creates an unnamed operator. |
|
| Method Summary | ||
|---|---|---|
void |
addError(java.lang.String message)
Adds an error message. |
|
void |
addValue(Value value)
Adds an implementation of Value. |
|
void |
addWarning(java.lang.String message)
Adds a warning message to the error list. |
|
abstract IOObject[] |
apply()
Implement this method in subclasses. |
|
IOContainer |
apply(IOContainer input)
Applies the operator. |
|
int |
checkDeprecations()
Will count an the number of deprecated operators, i.e. the operators which getDeprecationInfo() method does not return null. |
|
protected void |
checkForStop()
|
|
java.lang.Class<?>[] |
checkIO(java.lang.Class<?>[] input)
Subclasses will throw an exception if something isn't ok. |
|
int |
checkProperties()
Will count an error if a non optional property has no default value and is not defined by user. |
|
void |
clearErrorList()
Clears the list of errors. |
|
Operator |
cloneOperator(java.lang.String name)
Performs a deep clone on the most parts of this operator. |
|
java.lang.String |
createExperimentTree(int indent)
Deprecated. Use createProcessTree(int) instead |
|
protected java.lang.String |
createExperimentTree(int indent,
java.lang.String selfPrefix,
java.lang.String childPrefix,
Operator markOperator,
java.lang.String mark)
Deprecated. Use createProcessTree(int,String,String,Operator,String) instead |
|
static Operator |
createFromXML(org.w3c.dom.Element element,
java.util.List<UnknownParameterInformation> unknownParameterInformation)
|
|
java.lang.String |
createMarkedExperimentTree(int indent,
java.lang.String mark,
Operator markOperator)
Deprecated. Use createMarkedProcessTree(int,String,Operator) instead |
|
java.lang.String |
createMarkedProcessTree(int indent,
java.lang.String mark,
Operator markOperator)
Returns this operator's name and class. |
|
java.lang.String |
createProcessTree(int indent)
Returns this operator's name and class. |
|
protected java.lang.String |
createProcessTree(int indent,
java.lang.String selfPrefix,
java.lang.String childPrefix,
Operator markOperator,
java.lang.String mark)
Returns this operator's name and class. |
|
boolean |
getAddOnlyAdditionalOutput()
Indicates how additional output should be added to the IOContainer. |
|
int |
getApplyCount()
Returns the number of times this operator was already applied. |
|
protected java.lang.Class<?>[] |
getDeliveredOutputClasses()
Returns the classes that are guaranteed to be returned by apply(). |
|
java.lang.String |
getDeprecationInfo()
Returns null if this operator is not deprecated. |
|
protected java.lang.Class<?>[] |
getDesiredInputClasses()
Returns the classes that are needed as input. |
|
java.nio.charset.Charset |
getEncoding()
Returns the encoding if defined by the root operator if this operator is part of a process or the standard encoding defined via the system property. |
|
java.util.List<java.lang.String> |
getErrorList()
Returns a List of Strings containing error messages. |
|
Process |
getExperiment()
Deprecated. Please use getProcess() instead |
|
protected java.lang.String |
getInnerOperatorsXML(java.lang.String indent,
boolean hideDefault)
Writes the XML representation of the inner operators. |
|
protected IOContainer |
getInput()
Returns the complete input. |
|
protected
|
getInput(java.lang.Class<T> cls)
Returns an IOObject of class cls. |
|
protected
|
getInput(java.lang.Class<T> cls,
int nr)
Returns the nr-th IOObject of class cls. |
|
abstract java.lang.Class<?>[] |
getInputClasses()
Returns the classes that are needed as input. |
|
protected InputDescription |
getInputDescription(java.lang.Class<?> inputClass)
The default implementation returns an input description that consumes the input IOObject without a user parameter. |
|
protected IOContainer |
getIOContainerForInApplyLoopBreakpoint()
Returns the intermediate results of an in-apply-loop which will be displayed in case of a BreakpointListener.BREAKPOINT_WITHIN. |
|
protected IODescription |
getIODescription()
If you find the getInputClasses() and getOuputClasses() methods for some reason not useful, you may override this method. |
|
LogService |
getLog()
Returns the logging of the process if this operator is part of an process and the global logging service otherwise. |
|
java.lang.String |
getName()
Returns the name of the operator. |
|
java.lang.String |
getOperatorClassName()
Returns the "class name" of this operator from the operator description of the operator. |
|
OperatorDescription |
getOperatorDescription()
Returns the operator description of this operator. |
|
abstract java.lang.Class<?>[] |
getOutputClasses()
Returns the classes that are guaranteed to be returned by apply() as additional output. |
|
java.lang.String |
getParameter(java.lang.String key)
Returns a single parameter retrieved from the Parameters of this
Operator. |
|
boolean |
getParameterAsBoolean(java.lang.String key)
Returns a single named parameter and casts it to boolean. |
|
java.awt.Color |
getParameterAsColor(java.lang.String key)
Returns a single named parameter and casts it to Color. |
|
double |
getParameterAsDouble(java.lang.String key)
Returns a single named parameter and casts it to double. |
|
java.io.File |
getParameterAsFile(java.lang.String key)
Returns a single named parameter and casts it to File. |
|
java.io.File |
getParameterAsFile(java.lang.String key,
boolean createMissingDirectories)
Returns a single named parameter and casts it to File. |
|
java.io.InputStream |
getParameterAsInputStream(java.lang.String key)
Returns a single named parameter and tries to handle it as URL. |
|
int |
getParameterAsInt(java.lang.String key)
Returns a single named parameter and casts it to int. |
|
double[][] |
getParameterAsMatrix(java.lang.String key)
Returns a single named parameter and casts it to a double matrix. |
|
java.lang.String |
getParameterAsString(java.lang.String key)
Returns a single named parameter and casts it to String. |
|
java.util.List<java.lang.String[]> |
getParameterList(java.lang.String key)
Returns a single named parameter and casts it to List. |
|
Parameters |
getParameters()
Returns a collection of all parameters of this operator. |
|
ParameterType |
getParameterType(java.lang.String name)
Returns the parameter type with the given name. |
|
java.util.List<ParameterType> |
getParameterTypes()
Returns a list of ParameterTypes describing the parameters of this operator. |
|
OperatorChain |
getParent()
Returns the parent of this operator which must be an operator chain. |
|
Process |
getProcess()
Returns the process of this operator by asking the parent operator. |
|
long |
getStartTime()
Returns the system time when the operator was started. |
|
java.lang.String |
getStatus()
Returns human readable status information. |
|
java.lang.String |
getUserDescription()
The user specified comment for this operator. |
|
Value |
getValue(java.lang.String key)
Returns the value of the Value with the given key. |
|
java.util.Collection<Value> |
getValues()
Returns all Values sorted by key. |
|
java.lang.String |
getXML(java.lang.String indent,
boolean hideDefault)
Returns the XML representation of this operator. |
|
boolean |
hasBreakpoint()
Returns true iff this operator has a breakpoint at any possible position. |
|
boolean |
hasBreakpoint(int position)
Returns true iff a breakpoint is set at the given position |
|
protected boolean |
hasInput(java.lang.Class<? extends IOObject> cls)
Returns true if this operator has an input object of the desired class. |
|
void |
inApplyLoop()
Should be called if this operator performs a loop (for the loop time resetting used for Value creation used by DataTables). |
|
boolean |
isDebugMode()
|
|
boolean |
isEnabled()
Returns true if this operator is enabled and the parent (if not null) is also enabled. |
|
boolean |
isExpanded()
Returns true if this operator should be painted expanded. |
|
boolean |
isParallel()
This method must return true if the operator performs parallel execution of child operators and false otherwise. |
|
boolean |
isParameterSet(java.lang.String key)
Returns true iff the parameter with the given name is set. |
|
void |
log(java.lang.String message)
Logs a status message with the correct log service. |
|
void |
logError(java.lang.String message)
Logs an error message with the correct log service. |
|
void |
logNote(java.lang.String message)
Logs a note message with the correct log service. |
|
void |
logWarning(java.lang.String message)
Logs a warning message with the correct log service. |
|
void |
performAdditionalChecks()
This method is invoked during the validation checks. |
|
void |
processFinished()
Called at the end of the process. |
|
void |
processStarts()
Called when the process starts. |
|
void |
register(Process process,
java.lang.String name)
Deprecated. No longer necessary since the registering / unregistering will be performed during operator adding |
|
protected void |
registerOperator(Process process)
Registers this operator in the given process. |
|
void |
remove()
Removes this operator from its parent. |
|
java.lang.String |
rename(java.lang.String newName)
This method unregisters the old name if this operator is already part of a Process. |
|
void |
resume()
Deprecated. Use Process.resume() |
|
void |
setApplyCount(int applyCount)
|
|
void |
setBreakpoint(int position,
boolean on)
Sets or clears a breakpoint at the given position. |
|
void |
setEnabled(boolean enabled)
Sets the activation mode. |
|
void |
setExpanded(boolean expanded)
Sets the expansion mode which indicates if this operator is drawn expanded or not. |
|
protected void |
setInput(IOContainer input)
ATTENTION: Use this method only if you are ABSOLUTELY sure what you are doing! |
|
void |
setListParameter(java.lang.String key,
java.util.List<java.lang.String[]> list)
Sets the given parameter list to the Parameters object of this operator. |
|
void |
setOperatorParameters(org.w3c.dom.Element element,
java.util.List<UnknownParameterInformation> unknownParameterInformation)
Sets all parameters of this operator (including inner operators and their parameters). |
|
void |
setParameter(java.lang.String key,
java.lang.String value)
Sets the given single parameter to the Parameters object of this operator. |
|
void |
setParameters(Parameters parameters)
Sets all parameters of this operator. |
|
void |
setParent(OperatorChain parent)
Sets the enclosing operator chain. |
|
void |
setUserDescription(java.lang.String description)
Sets the user specified comment for this operator. |
|
java.lang.String |
toString()
Returns the name. |
|
protected void |
unregisterOperator(Process process)
Deletes this operator removing it from the name map of the process. |
|
void |
writeXML(java.io.PrintWriter out,
java.lang.String indent,
boolean hideDefault)
Writes the XML representation of this operator. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Operator(OperatorDescription description)
Creates an unnamed operator. Subclasses must pass the given description object to this super-constructor (i.e. invoking super(OperatorDescription)). They might also add additional values for process logging.
NOTE: the preferred way for operator creation is using one of the factory
methods of OperatorService.
| Method Detail |
|---|
public final OperatorDescription getOperatorDescription()
public final java.lang.String getOperatorClassName()
@Deprecated public Process getExperiment()
getProcess() instead
public Process getProcess()
getProcess in interface ConfigurationListenergetProcess in interface PreviewListenerpublic LogService getLog()
public void log(java.lang.String message)
log in interface LoggingHandlerpublic void logNote(java.lang.String message)
logNote in interface LoggingHandlerpublic void logWarning(java.lang.String message)
logWarning in interface LoggingHandlerpublic void logError(java.lang.String message)
logError in interface LoggingHandlerpublic final java.lang.String getName()
public final java.lang.String rename(java.lang.String newName)
Process. Afterwards,
the new name is set and registered in the process. Please note that the name might be changed
during registering in order to ensure that each operator name is unique in its process.
The new name will be returned.
public void setUserDescription(java.lang.String description)
public java.lang.String getUserDescription()
public final java.lang.String getDeprecationInfo()
public final void setParent(OperatorChain parent)
public final OperatorChain getParent()
public void remove()
@Deprecated
public void register(Process process,
java.lang.String name)
protected void registerOperator(Process process)
protected void unregisterOperator(Process process)
public void setEnabled(boolean enabled)
public void setExpanded(boolean expanded)
public boolean isExpanded()
public boolean isEnabled()
public boolean isParallel()
public java.lang.String getStatus()
public int getApplyCount()
public Operator cloneOperator(java.lang.String name)
public abstract IOObject[] apply()
throws OperatorException
OperatorExceptionpublic abstract java.lang.Class<?>[] getInputClasses()
getOutputClasses() and
apply() if this is necessary. This default behavior can be
changed by overriding getInputDescription(Class). Subclasses
which implement this method should not make use of parameters since this
method is invoked by getParameterTypes(). Therefore, parameters are not
fully available at this point of time and this might lead to exceptions.
Please use InputDescriptions instead.
public abstract java.lang.Class<?>[] getOutputClasses()
Returns the classes that are guaranteed to be returned by
apply() as additional output. Please note that input objects
which should not be consumed must also be defined by this method (e.g.
an example set which is changed but not consumed in the case of a preprocessing
operator must be defined in both, the methods getInputClasses() and
getOutputClasses()). The default behavior for input consumation
is defined by getInputDescription(Class) and can be changed by
overwriting this method. Objects which are not consumed (defined by changing
the implementation in getInputDescription(Class)) must not be
defined as additional output in this method.
May deliver null or an empy array (no additional output is produced or guaranteed). Must return the class array of delivered output objects otherwise.
protected final java.lang.Class<?>[] getDesiredInputClasses()
getInputClasses().
protected final java.lang.Class<?>[] getDeliveredOutputClasses()
protected InputDescription getInputDescription(java.lang.Class<?> inputClass)
protected IODescription getIODescription()
public java.lang.Class<?>[] checkIO(java.lang.Class<?>[] input)
throws IllegalInputException,
WrongNumberOfInnerOperatorsException
IllegalInputException
WrongNumberOfInnerOperatorsException
public void performAdditionalChecks()
throws UserError
UserErrorpublic int checkProperties()
public int checkDeprecations()
getDeprecationInfo() method does not return null. Returns
the total number of deprecations.
public final IOContainer apply(IOContainer input)
throws OperatorException
OperatorException
protected final void checkForStop()
throws ProcessStoppedException
ProcessStoppedException@Deprecated public final void resume()
Process.resume()
public boolean getAddOnlyAdditionalOutput()
protected <T extends IOObject> T getInput(java.lang.Class<T> cls)
throws MissingIOObjectException
MissingIOObjectException
protected <T extends IOObject> T getInput(java.lang.Class<T> cls,
int nr)
throws MissingIOObjectException
MissingIOObjectExceptionprotected boolean hasInput(java.lang.Class<? extends IOObject> cls)
protected final IOContainer getInput()
getInput(Class). However, some
operator chains must handle their inner input and have to use the
IOContainer directly.
protected void setInput(IOContainer input)
public void processStarts()
throws OperatorException
OperatorException
public void processFinished()
throws OperatorException
OperatorException
public void setBreakpoint(int position,
boolean on)
position - One out of BREAKPOINT_BEFORE and BREAKPOINT_AFTERpublic boolean hasBreakpoint()
public boolean hasBreakpoint(int position)
position - One out of BREAKPOINT_BEFORE and BREAKPOINT_AFTER
public void inApplyLoop()
throws ProcessStoppedException
getIOContainerForInApplyLoopBreakpoint()
in case of a BreakpointListener.BREAKPOINT_WITHIN. Subclasses should invoke this method in case
of a loop in their method apply(). This method also invokes checkForStop().
ProcessStoppedExceptionprotected IOContainer getIOContainerForInApplyLoopBreakpoint()
BreakpointListener.BREAKPOINT_WITHIN.
public void addValue(Value value)
public final Value getValue(java.lang.String key)
public java.util.Collection<Value> getValues()
public Parameters getParameters()
getParameters in interface ConfigurationListenergetParameters in interface PreviewListenergetParameters in interface ParameterHandlerpublic void setParameters(Parameters parameters)
setParameters in interface ConfigurationListenersetParameters in interface ParameterHandler
public void setParameter(java.lang.String key,
java.lang.String value)
setListParameter(String, List) should be used.
setParameter in interface ParameterHandler
public void setListParameter(java.lang.String key,
java.util.List<java.lang.String[]> list)
setParameter(String, String)
should be used.
setListParameter in interface ParameterHandler
public java.lang.String getParameter(java.lang.String key)
throws UndefinedParameterError
Parameters of this
Operator.
getParameter in interface ParameterHandlerUndefinedParameterError
public boolean isParameterSet(java.lang.String key)
throws UndefinedParameterError
isParameterSet in interface ParameterHandlerUndefinedParameterError
public java.lang.String getParameterAsString(java.lang.String key)
throws UndefinedParameterError
getParameterAsString in interface ParameterHandlerUndefinedParameterError
public int getParameterAsInt(java.lang.String key)
throws UndefinedParameterError
getParameterAsInt in interface ParameterHandlerUndefinedParameterError
public double getParameterAsDouble(java.lang.String key)
throws UndefinedParameterError
getParameterAsDouble in interface ParameterHandlerUndefinedParameterErrorpublic boolean getParameterAsBoolean(java.lang.String key)
getParameterAsBoolean in interface ParameterHandler
public java.util.List<java.lang.String[]> getParameterList(java.lang.String key)
throws UndefinedParameterError
getParameterList in interface ParameterHandlerUndefinedParameterError
public java.awt.Color getParameterAsColor(java.lang.String key)
throws UndefinedParameterError
getParameterAsColor in interface ParameterHandlerUndefinedParameterError
public java.io.InputStream getParameterAsInputStream(java.lang.String key)
throws UndefinedParameterError,
java.io.IOException
Process.resolveFileName(String).
getParameterAsInputStream in interface ParameterHandlerUndefinedParameterError
java.io.IOException
public java.io.File getParameterAsFile(java.lang.String key)
throws UndefinedParameterError
Process.resolveFileName(String).
getParameterAsFile in interface ParameterHandlerUndefinedParameterError
public java.io.File getParameterAsFile(java.lang.String key,
boolean createMissingDirectories)
throws UndefinedParameterError
Process.resolveFileName(String).
getParameterAsFile in interface ParameterHandlerUndefinedParameterError
public double[][] getParameterAsMatrix(java.lang.String key)
throws UndefinedParameterError
getParameterAsMatrix in interface ParameterHandlerUndefinedParameterErrorpublic java.util.List<ParameterType> getParameterTypes()
getParameterTypes in interface ParameterHandlerpublic ParameterType getParameterType(java.lang.String name)
public void writeXML(java.io.PrintWriter out,
java.lang.String indent,
boolean hideDefault)
throws java.io.IOException
java.io.IOException
public java.lang.String getXML(java.lang.String indent,
boolean hideDefault)
protected java.lang.String getInnerOperatorsXML(java.lang.String indent,
boolean hideDefault)
public static Operator createFromXML(org.w3c.dom.Element element,
java.util.List<UnknownParameterInformation> unknownParameterInformation)
throws XMLException
XMLException
public void setOperatorParameters(org.w3c.dom.Element element,
java.util.List<UnknownParameterInformation> unknownParameterInformation)
throws XMLException
XMLExceptionpublic void clearErrorList()
addError(String)public void addError(java.lang.String message)
getErrorList()public void addWarning(java.lang.String message)
getErrorList()public java.util.List<java.lang.String> getErrorList()
addError(String)public long getStartTime()
public java.lang.String toString()
toString in class java.lang.Object@Deprecated public java.lang.String createExperimentTree(int indent)
createProcessTree(int) instead
public java.lang.String createProcessTree(int indent)
@Deprecated
public java.lang.String createMarkedExperimentTree(int indent,
java.lang.String mark,
Operator markOperator)
createMarkedProcessTree(int,String,Operator) instead
public java.lang.String createMarkedProcessTree(int indent,
java.lang.String mark,
Operator markOperator)
@Deprecated
protected java.lang.String createExperimentTree(int indent,
java.lang.String selfPrefix,
java.lang.String childPrefix,
Operator markOperator,
java.lang.String mark)
createProcessTree(int,String,String,Operator,String) instead
protected java.lang.String createProcessTree(int indent,
java.lang.String selfPrefix,
java.lang.String childPrefix,
Operator markOperator,
java.lang.String mark)
public final java.nio.charset.Charset getEncoding()
public boolean isDebugMode()
public void setApplyCount(int applyCount)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||