|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.core.node.NodeModel
org.knime.base.node.mine.cluster.kmeans.ClusterNodeModel
public class ClusterNodeModel
Generate a clustering using a fixed number of cluster centers and the k-means
algorithm. Right now this works only on DataTable
s holding
DoubleCell
s (or derivatives thereof).
Field Summary | |
---|---|
static String |
CFG_COLUMNS
Config key for the used columns. |
static String |
CFG_MAX_ITERATIONS
Config key for the maximal number of iterations. |
static String |
CFG_NR_OF_CLUSTERS
Config key for the number of clusters. |
static String |
CLUSTER
Constant for the RowKey generation and identification in the view. |
static int |
INITIAL_MAX_ITERATIONS
Constant for the initial number of iterations used in the dialog. |
static int |
INITIAL_NR_CLUSTERS
Constant for the initial number of clusters used in the dialog. |
Constructor Summary | |
---|---|
ClusterNodeModel()
Constructor, remember parent and initialize status. |
Method Summary | |
---|---|
protected PortObjectSpec[] |
configure(PortObjectSpec[] inSpecs)
Returns true always and passes the current input spec to
the output spec which is identical to the input specification - after
all, we are building cluster centers in the original feature space. |
protected PortObject[] |
execute(PortObject[] data,
ExecutionContext exec)
Generate new clustering based on InputDataTable and specified number of clusters. |
(package private) double[] |
getClusterCenter(int c)
Return prototype vector of cluster c. |
(package private) int |
getClusterCoverage(int c)
Return coverage of a cluster. |
(package private) int |
getDimension()
Return dimension of feature space (and hence also clusters). |
(package private) String |
getFeatureName(int i)
Return name of column at i'th postion within cluster prototype. |
(package private) HiLiteHandler |
getHiLiteHandler()
|
(package private) int |
getMaxNumIterations()
Get maximum number of iterations for batch mode. |
(package private) int |
getNrUsedColumns()
|
(package private) int |
getNumClusters()
Get number of clusters. |
protected HiLiteHandler |
getOutHiLiteHandler(int outIndex)
Returns the HiLiteHandler for the given output index. |
(package private) boolean |
hasModel()
|
protected void |
loadInternals(File internDir,
ExecutionMonitor exec)
Load internals into the derived NodeModel . |
protected void |
loadValidatedSettingsFrom(NodeSettingsRO settings)
Method is called when the NodeModel has to set its
configuration using the given one. |
protected void |
reset()
Clears the model. |
protected void |
saveInternals(File internDir,
ExecutionMonitor exec)
Save internals of the derived NodeModel . |
protected void |
saveSettingsTo(NodeSettingsWO settings)
Appends to the given node settings the model specific configuration, that are, the current settings (e.g. |
protected void |
setInHiLiteHandler(int inIndex,
HiLiteHandler hiLiteHdl)
This implementation is empty. |
(package private) void |
setMaxNumIterations(int i)
Set maximum number of iterations for batch mode. |
(package private) void |
setNumClusters(int n)
Set number of clusters. |
protected void |
validateSettings(NodeSettingsRO settings)
Method is called when before the model has to change it's configuration (@see loadsettings) using the given one. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CLUSTER
public static final int INITIAL_NR_CLUSTERS
public static final int INITIAL_MAX_ITERATIONS
public static final String CFG_NR_OF_CLUSTERS
public static final String CFG_MAX_ITERATIONS
public static final String CFG_COLUMNS
Constructor Detail |
---|
ClusterNodeModel()
Method Detail |
---|
final HiLiteHandler getHiLiteHandler()
protected HiLiteHandler getOutHiLiteHandler(int outIndex)
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.
getOutHiLiteHandler
in class NodeModel
outIndex
- The output index.
HiLiteHandler
for the given output port.protected void setInHiLiteHandler(int inIndex, HiLiteHandler hiLiteHdl)
setInHiLiteHandler
in class NodeModel
inIndex
- The index of the input.hiLiteHdl
- The HiLiteHandler
at input index.
May be null
when not available, i.e. not properly
connected.protected void saveSettingsTo(NodeSettingsWO settings)
NodeDialogPane
), as wells, the
NodeModel
itself if applicable.
Method is called by the Node
if the
current configuration needs to be saved.
saveSettingsTo
in class NodeModel
settings
- to write intoNodeModel.loadValidatedSettingsFrom(NodeSettingsRO)
,
NodeModel.validateSettings(NodeSettingsRO)
protected void validateSettings(NodeSettingsRO settings) throws InvalidSettingsException
Node
.
validateSettings
in class NodeModel
settings
- to validate
InvalidSettingsException
- if a property is not available or
doesn't fitNodeModel.saveSettingsTo(NodeSettingsWO)
,
NodeModel.loadValidatedSettingsFrom(NodeSettingsRO)
protected void loadValidatedSettingsFrom(NodeSettingsRO settings) throws InvalidSettingsException
NodeModel
has to set its
configuration using the given one. This method is also called by the
Node
. Note that the settings should
have been validated before this method is called.
loadValidatedSettingsFrom
in class NodeModel
settings
- to read from
InvalidSettingsException
- if a property is not available - which
shouldn't happen...NodeModel.saveSettingsTo(NodeSettingsWO)
,
NodeModel.validateSettings(NodeSettingsRO)
int getNumClusters()
void setNumClusters(int n)
n
- number of clustersint getMaxNumIterations()
void setMaxNumIterations(int i)
i
- maximum number of iterationsint getDimension()
int getNrUsedColumns()
boolean hasModel()
double[] getClusterCenter(int c)
c
- index of cluster
String getFeatureName(int i)
i
- index of (double compatible = not ignored) feature
int getClusterCoverage(int c)
c
- index of cluster
protected PortObject[] execute(PortObject[] data, ExecutionContext exec) throws Exception
PortObject classes
that are defined through the
PortTypes
given in the
constructor
.
Similarly, the returned output objects need to comply with their port
types object class (otherwise an error is reported by the framework).
For a general description of the execute method refer to the description
of the specialized
NodeModel.execute(BufferedDataTable[], ExecutionContext)
methods as it
addresses more use cases.
execute
in class NodeModel
data
- The input objects.exec
- For BufferedDataTable
creation and progress.
Exception
- If the node execution fails for any reason.protected void reset()
reset
in class NodeModel
NodeModel.reset()
protected PortObjectSpec[] configure(PortObjectSpec[] inSpecs) throws InvalidSettingsException
true
always and passes the current input spec to
the output spec which is identical to the input specification - after
all, we are building cluster centers in the original feature space.
configure
in class NodeModel
inSpecs
- the specifications of the input port(s) - should be one
InvalidSettingsException
- if PMML incompatible type was foundprotected void loadInternals(File internDir, ExecutionMonitor exec) throws IOException
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.
loadInternals
in class NodeModel
internDir
- The directory to read from.exec
- Used to report progress and to cancel the load process.
IOException
- If an error occurs during reading from this dir.NodeModel.saveInternals(File,ExecutionMonitor)
protected void saveInternals(File internDir, ExecutionMonitor exec) throws IOException, CanceledExecutionException
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.
saveInternals
in class NodeModel
internDir
- The directory to write into.exec
- Used to report progress and to cancel the save process.
IOException
- If an error occurs during writing to this dir.
CanceledExecutionException
- If the saving has been canceled.NodeModel.loadInternals(File,ExecutionMonitor)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |