org.knime.base.node.mine.bfn
Class BasisFunctionLearnerNodeModel

java.lang.Object
  extended by org.knime.core.node.NodeModel
      extended by org.knime.base.node.mine.bfn.BasisFunctionLearnerNodeModel
Direct Known Subclasses:
FuzzyBasisFunctionLearnerNodeModel, RadialBasisFunctionLearnerNodeModel

public abstract class BasisFunctionLearnerNodeModel
extends NodeModel

Abstract basisfunction model holding the trained rule table.

Author:
Thomas Gabriel, University of Konstanz

Field Summary
static String DISTANCE
          Key for choice of distance measure.
static Distance[] DISTANCES
          An array of possible distance measures.
static String HILITE_MAPPING_FILE_NAME
          File name for hilite mapping.
static String MAX_CLASS_COVERAGE
          NodeSettings key for max_class_coverage.
static String MAX_EPOCHS
          Config key for maximum number of epochs.
static String MODEL_INFO
          Model info identifier.
static String MODEL_INFO_FILE_NAME
          Model info file extension.
static String SHRINK_AFTER_COMMIT
          NodeSettings key for shrink_after_commit.
static String TARGET_COLUMNS
          Key of the target column.
 
Constructor Summary
protected BasisFunctionLearnerNodeModel(PortType model)
          Creates a new model with one data in and out port, and model out-port.
 
Method Summary
 PortObjectSpec[] configure(PortObjectSpec[] ins)
          Configure method for general port types.
abstract  BasisFunctionPortObject createPortObject(BasisFunctionModelContent content)
          Creates a new basisfunction port object given the model content.
 PortObject[] execute(PortObject[] inData, ExecutionContext exec)
          Starts the learning algorithm in the learner.
 int getDistance()
           
abstract  BasisFunctionFactory getFactory(DataTableSpec spec)
          Create factory to generate BasisFunctions.
 int getMaxNrEpochs()
           
 BasisFunctionLearnerTable.MissingValueReplacementFunction getMissingFct()
           
 ModelContentRO getModelInfo()
           
abstract  DataType getModelType()
           
 HiLiteHandler getOutHiLiteHandler(int outPortID)
          Returns the HiLiteHandler for the given output index.
 String[] getTargetColumns()
           
 boolean isMaxClassCoverage()
           
 boolean isShrinkAfterCommit()
           
protected  void loadInternals(File internDir, ExecutionMonitor exec)
          Load internals into the derived NodeModel.
 void loadValidatedSettingsFrom(NodeSettingsRO settings)
          Sets new settings from the passed object in the model.
protected  void reset()
          Reset the trained model.
protected  void saveInternals(File internDir, ExecutionMonitor exec)
          Save internals of the derived NodeModel.
 void saveSettingsTo(NodeSettingsWO settings)
          Adds to the given NodeSettings the model specific settings.
protected  void setInHiLiteHandler(int inIndex, HiLiteHandler hiLiteHdl)
          This implementation is empty.
 void validateSettings(NodeSettingsRO settings)
          Validates the settings in the passed NodeSettings object.
 
Methods inherited from class org.knime.core.node.NodeModel
addWarningListener, configure, continueLoop, execute, executeModel, getInHiLiteHandler, getLoopEndNode, getLoopStartNode, getNrInPorts, getNrOutPorts, getWarningMessage, notifyViews, notifyWarningListeners, peekFlowVariableDouble, peekFlowVariableInt, peekFlowVariableString, peekScopeVariableDouble, peekScopeVariableInt, peekScopeVariableString, pushFlowVariableDouble, pushFlowVariableInt, pushFlowVariableString, pushScopeVariableDouble, pushScopeVariableInt, pushScopeVariableString, removeWarningListener, setWarningMessage, stateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISTANCE

public static final String DISTANCE
Key for choice of distance measure.

See Also:
Constant Field Values

DISTANCES

public static final Distance[] DISTANCES
An array of possible distance measures.


SHRINK_AFTER_COMMIT

public static final String SHRINK_AFTER_COMMIT
NodeSettings key for shrink_after_commit.

See Also:
Constant Field Values

MAX_CLASS_COVERAGE

public static final String MAX_CLASS_COVERAGE
NodeSettings key for max_class_coverage.

See Also:
Constant Field Values

TARGET_COLUMNS

public static final String TARGET_COLUMNS
Key of the target column.

See Also:
Constant Field Values

MAX_EPOCHS

public static final String MAX_EPOCHS
Config key for maximum number of epochs.

See Also:
Constant Field Values

MODEL_INFO

public static final String MODEL_INFO
Model info identifier.

See Also:
Constant Field Values

MODEL_INFO_FILE_NAME

public static final String MODEL_INFO_FILE_NAME
Model info file extension.

See Also:
Constant Field Values

HILITE_MAPPING_FILE_NAME

public static final String HILITE_MAPPING_FILE_NAME
File name for hilite mapping.

See Also:
Constant Field Values
Constructor Detail

BasisFunctionLearnerNodeModel

protected BasisFunctionLearnerNodeModel(PortType model)
Creates a new model with one data in and out port, and model out-port.

Parameters:
model - the port type of the generated basisfunction model
Method Detail

reset

protected void reset()
Reset the trained model. Override this function in the derived model and reset your NodeModel. All components should unregister themselves from any observables (at least from the hilite handler right now). All internally stored data structures should be released. User settings should not be deleted/reset though.

Specified by:
reset in class NodeModel

setInHiLiteHandler

protected void setInHiLiteHandler(int inIndex,
                                  HiLiteHandler hiLiteHdl)
This implementation is empty. Subclasses may override this method in order to be informed when the hilite handler changes at the inport, e.g. when the node (or an preceding node) is newly connected.

Overrides:
setInHiLiteHandler in class NodeModel
Parameters:
inIndex - The index of the input.
hiLiteHdl - The HiLiteHandler at input index. May be null when not available, i.e. not properly connected.

getOutHiLiteHandler

public HiLiteHandler getOutHiLiteHandler(int outPortID)
Returns the HiLiteHandler for the given output index. This default implementation simply passes on the handler of input port 0 or generates a new one if this node has no inputs.

This method is intended to be overridden

Overrides:
getOutHiLiteHandler in class NodeModel
Parameters:
outPortID - The output index.
Returns:
HiLiteHandler for the given output port.

configure

public PortObjectSpec[] configure(PortObjectSpec[] ins)
                           throws InvalidSettingsException
Configure method for general port types. The argument specs represent the input object specs and are guaranteed to be subclasses of the PortObjectSpecs that are defined through the PortTypes given in the constructor. Similarly, the returned output specs need to comply with their port types spec class (otherwise an error is reported by the framework). They may also be null.

For a general description of the configure method refer to the description of the specialized NodeModel.configure(DataTableSpec[]) methods as it addresses more use cases.

Overrides:
configure in class NodeModel
Parameters:
ins - The input object specs.
Returns:
The output objects specs or null.
Throws:
InvalidSettingsException - If this node can't be configured.

getModelType

public abstract DataType getModelType()
Returns:
the type of the learned model cells

createPortObject

public abstract BasisFunctionPortObject createPortObject(BasisFunctionModelContent content)
Creates a new basisfunction port object given the model content.

Parameters:
content - basisfunction rules and spec
Returns:
a new basisfunction port object

execute

public PortObject[] execute(PortObject[] inData,
                            ExecutionContext exec)
                     throws CanceledExecutionException
Starts the learning algorithm in the learner.

Overrides:
execute in class NodeModel
Parameters:
inData - the input training data at index 0
exec - the execution monitor
Returns:
the output fuzzy rule model
Throws:
CanceledExecutionException - if the training was canceled

getFactory

public abstract BasisFunctionFactory getFactory(DataTableSpec spec)
Create factory to generate BasisFunctions.

Parameters:
spec - the cleaned data for training
Returns:
factory to create special basis function rules

getModelInfo

public ModelContentRO getModelInfo()
Returns:
get model info after training or null

validateSettings

public void validateSettings(NodeSettingsRO settings)
                      throws InvalidSettingsException
Validates the settings in the passed NodeSettings object. The specified settings should be checked for completeness and consistency. It must be possible to load a settings object validated here without any exception in the #loadValidatedSettings(NodeSettings) method. The method must not change the current settings in the model - it is supposed to just check them. If some settings are missing, invalid, inconsistent, or just not right throw an exception with a message useful to the user.

Specified by:
validateSettings in class NodeModel
Parameters:
settings - The settings to validate.
Throws:
InvalidSettingsException - If the validation of the settings failed.
See Also:
NodeModel.saveSettingsTo(NodeSettingsWO), NodeModel.loadValidatedSettingsFrom(NodeSettingsRO)

loadValidatedSettingsFrom

public void loadValidatedSettingsFrom(NodeSettingsRO settings)
                               throws InvalidSettingsException
Sets new settings from the passed object in the model. You can safely assume that the object passed has been successfully validated by the #validateSettings(NodeSettings) method. The model must set its internal configuration according to the settings object passed.

Specified by:
loadValidatedSettingsFrom in class NodeModel
Parameters:
settings - The settings to read.
Throws:
InvalidSettingsException - If a property is not available.
See Also:
NodeModel.saveSettingsTo(NodeSettingsWO), NodeModel.validateSettings(NodeSettingsRO)

saveSettingsTo

public void saveSettingsTo(NodeSettingsWO settings)
Adds to the given NodeSettings the model specific settings. The settings don't need to be complete or consistent. If, right after startup, no valid settings are available this method can write either nothing or invalid settings.

Method is called by the Node if the current settings need to be saved or transfered to the node's dialog.

Specified by:
saveSettingsTo in class NodeModel
Parameters:
settings - The object to write settings into.
See Also:
NodeModel.loadValidatedSettingsFrom(NodeSettingsRO), NodeModel.validateSettings(NodeSettingsRO)

loadInternals

protected void loadInternals(File internDir,
                             ExecutionMonitor exec)
                      throws IOException,
                             CanceledExecutionException
Load internals into the derived NodeModel. This method is only called if the Node was executed. Read all your internal structures from the given file directory to create your internal data structure which is necessary to provide all node functionalities after the workflow is loaded, e.g. view content and/or hilite mapping.

Specified by:
loadInternals in class NodeModel
Parameters:
internDir - The directory to read from.
exec - Used to report progress and to cancel the load process.
Throws:
IOException - If an error occurs during reading from this dir.
CanceledExecutionException - If the loading has been canceled.
See Also:
NodeModel.saveInternals(File,ExecutionMonitor)

saveInternals

protected void saveInternals(File internDir,
                             ExecutionMonitor exec)
                      throws IOException,
                             CanceledExecutionException
Save internals of the derived NodeModel. This method is only called if the Node is executed. Write all your internal structures into the given file directory which are necessary to recreate this model when the workflow is loaded, e.g. view content and/or hilite mapping.

Specified by:
saveInternals in class NodeModel
Parameters:
internDir - The directory to write into.
exec - Used to report progress and to cancel the save process.
Throws:
IOException - If an error occurs during writing to this dir.
CanceledExecutionException - If the saving has been canceled.
See Also:
NodeModel.loadInternals(File,ExecutionMonitor)

getMissingFct

public final BasisFunctionLearnerTable.MissingValueReplacementFunction getMissingFct()
Returns:
missing replacement function

getTargetColumns

public final String[] getTargetColumns()
Returns:
the target columns with class info

isShrinkAfterCommit

public final boolean isShrinkAfterCommit()
Returns:
true if shrink after commit

isMaxClassCoverage

public final boolean isMaxClassCoverage()
Returns:
true if max class coverage

getDistance

public final int getDistance()
Returns:
the choice of distance function

getMaxNrEpochs

public final int getMaxNrEpochs()
Returns:
maximum number of epochs to train


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.