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

java.lang.Object
  extended by org.knime.base.node.mine.bfn.BasisFunctionLearnerRow
All Implemented Interfaces:
Iterable<DataCell>, DataRow
Direct Known Subclasses:
FuzzyBasisFunctionLearnerRow, RadialBasisFunctionLearnerRow

public abstract class BasisFunctionLearnerRow
extends Object
implements DataRow

General BasisFunctionLearnerRow prototype which provides functions to shrink, cover, and reset rules; and to be compared with others by its coverage. This basis function also keeps a list of all covered training examples.

Author:
Thomas Gabriel, University of Konstanz

Constructor Summary
protected BasisFunctionLearnerRow(RowKey key, DataRow centroid, DataCell classInfo)
          Initialise a new basisfunction rule with one covered pattern since this rule is also covered by itself.
 
Method Summary
 void addCovered(DataRow row, DataCell classInfo)
          If a new instance of this class is covered.
abstract  boolean compareCoverage(BasisFunctionLearnerRow o, DataRow r)
          Compares coverage of this and another row.
abstract  double computeActivation(DataRow row)
          Computes activation for a given row using this basis function.
 double computeCoverage(BasisFunctionLearnerRow bf)
          Computes the intersection of instances covered by this and the other basisfunction - its fraction to the total number of instances is returned.
abstract  void cover(DataRow row)
          Called if a row covers a new DataRow.
(package private)  void coverIntern(DataRow row)
          Covers a new row and decrease covered counter.
abstract  boolean covers(DataRow row)
          Returns true if the input row is covered by this row, otherwise false.
 boolean equals(Object o)
          Check if two BasisFunctionLearnerRow objects are equal if their centroids and class labels are equal.
abstract  boolean explains(DataRow row)
          Returns true if the input row is explained by this row, otherwise false.
 Set<RowKey> getAllCoveredPattern()
          Returns a set which contains all input training pattern covered by this basis function.
 DataRow getAnchor()
          Returns the basisfunction's anchor vector.
 DataCell getCell(int index)
          Returns the DataCell at the provided index within this row.
 DataCell getClassLabel()
           
abstract  DataCell getFinalCell(int index)
          Returns a basis function cell for the given index.
 RowKey getKey()
          Returns the row key.
abstract  DoubleValue getMissingValue(int col)
           
 int getNumCells()
          Returns the length of this row, that is the number of columns of the DataTable (not including the row key).
abstract  BasisFunctionPredictorRow getPredictorRow()
           
abstract  boolean getShrinkValue(DataRow row)
          Called if a new row has to be adjusted.
 double getVariance()
          Returns the within-cluster variance.
 int hashCode()
          Returns a hash code computed by the product of the hash code of anchor and class label.
 Iterator<DataCell> iterator()
          
 void print(PrintStream out)
          Writes information retrieved from the toString() method to the given stream.
abstract  void reset()
          Called if the algorithms starts a new run overall input pattern; some variables might need to be reset.
(package private)  void resetIntern()
          Resets the number of covered pattern to zero and calls the abstract reset().
abstract  boolean shrink(DataRow row)
          Called if a new row has to be adjusted, all conflicting rows are shrunken.
 String toString()
          Returns a string summary of this basis function cell including the assigned class, number of covered, as well as explained pattern.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasisFunctionLearnerRow

protected BasisFunctionLearnerRow(RowKey key,
                                  DataRow centroid,
                                  DataCell classInfo)
Initialise a new basisfunction rule with one covered pattern since this rule is also covered by itself. The number of explained pattern is set to zero.

Parameters:
key - of this row
centroid - the initial center vector
classInfo - the class info value
Method Detail

getPredictorRow

public abstract BasisFunctionPredictorRow getPredictorRow()
Returns:
underlying predictor row

getAnchor

public final DataRow getAnchor()
Returns the basisfunction's anchor vector.

Returns:
the initial anchor

getNumCells

public int getNumCells()
Returns the length of this row, that is the number of columns of the DataTable (not including the row key).

Specified by:
getNumCells in interface DataRow
Returns:
length of this row

getKey

public RowKey getKey()
Returns the row key.

Specified by:
getKey in interface DataRow
Returns:
the row key

getClassLabel

public final DataCell getClassLabel()
Returns:
The class label for this rule.

getCell

public DataCell getCell(int index)
Returns the DataCell at the provided index within this row.

Specified by:
getCell in interface DataRow
Parameters:
index - the index of the cell to retrieve (indices start from 0)
Returns:
the DataCell at the given index

iterator

public Iterator<DataCell> iterator()

Specified by:
iterator in interface Iterable<DataCell>

getFinalCell

public abstract DataCell getFinalCell(int index)
Returns a basis function cell for the given index.

Parameters:
index - cell for index
Returns:
a basis function cell

getMissingValue

public abstract DoubleValue getMissingValue(int col)
Parameters:
col - the column index
Returns:
a prediction for this basis function dimension

compareCoverage

public abstract boolean compareCoverage(BasisFunctionLearnerRow o,
                                        DataRow r)
Compares coverage of this and another row. This method is used in order to find the best basisfunction for a certain input pattern. If this covers better, return true.

Parameters:
o - the row to check with
r - the row to compute coverage on
Returns:
true this BasisFunction covers better than the other
Throws:
NullPointerException - if the given other basis function is null

getAllCoveredPattern

public final Set<RowKey> getAllCoveredPattern()
Returns a set which contains all input training pattern covered by this basis function.

Returns:
set of covered input pattern

getVariance

public final double getVariance()
Returns the within-cluster variance.

Returns:
within-cluster variance

addCovered

public final void addCovered(DataRow row,
                             DataCell classInfo)
If a new instance of this class is covered.

Parameters:
row - to cover
classInfo - and class.

resetIntern

final void resetIntern()
Resets the number of covered pattern to zero and calls the abstract reset().


coverIntern

final void coverIntern(DataRow row)
Covers a new row and decrease covered counter. Also calls the abstract cover(DataRow) method.

Parameters:
row - the data row to cover

computeCoverage

public final double computeCoverage(BasisFunctionLearnerRow bf)
Computes the intersection of instances covered by this and the other basisfunction - its fraction to the total number of instances is returned.

Parameters:
bf - the other basisfunction to get covered instances from
Returns:
the intersection ratio of both covered sets

print

public final void print(PrintStream out)
Writes information retrieved from the toString() method to the given stream.

Parameters:
out - the PrintStream to add info
Throws:
NullPointerException - if out is null.
See Also:
toString()

toString

public String toString()
Returns a string summary of this basis function cell including the assigned class, number of covered, as well as explained pattern. This method is supposed to be overridden to add additional information for a particular model.

Overrides:
toString in class Object
Returns:
string summary for this basisfunction cell

computeActivation

public abstract double computeActivation(DataRow row)
Computes activation for a given row using this basis function.

Parameters:
row - the data row to compute activation with
Returns:
the activation of the row

covers

public abstract boolean covers(DataRow row)
Returns true if the input row is covered by this row, otherwise false. Means, the minimum coverage criteria is fulfilled.

Parameters:
row - to check coverage
Returns:
true if covered, otherwise false

explains

public abstract boolean explains(DataRow row)
Returns true if the input row is explained by this row, otherwise false. Means, the maximum coverage criteria is fulfilled.

Parameters:
row - to check coverage
Returns:
true if explained, otherwise false

getShrinkValue

public abstract boolean getShrinkValue(DataRow row)
Called if a new row has to be adjusted.

Parameters:
row - conflicting pattern
Returns:
a value greater zero if a conflict has to be solved. The value indicates relative loss in coverage for this basis function.

shrink

public abstract boolean shrink(DataRow row)
Called if a new row has to be adjusted, all conflicting rows are shrunken.

Parameters:
row - conflicting pattern
Returns:
true if this basis function was effected by any change, otherwise false

reset

public abstract void reset()
Called if the algorithms starts a new run overall input pattern; some variables might need to be reset.


cover

public abstract void cover(DataRow row)
Called if a row covers a new DataRow.

Parameters:
row - the new covered DataRow

equals

public boolean equals(Object o)
Check if two BasisFunctionLearnerRow objects are equal if their centroids and class labels are equal.

Overrides:
equals in class Object
Parameters:
o - the other object to check
Returns:
true if this instance and the given object are instances of the same class and the centroid vector and class label are equal

hashCode

public int hashCode()
Returns a hash code computed by the product of the hash code of anchor and class label.

Overrides:
hashCode in class Object
Returns:
A new hash code.


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.