weka.classifiers.rules
Class NNge.Exemplar

java.lang.Object
  extended byweka.core.Instances
      extended byweka.classifiers.rules.NNge.Exemplar
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
NNge

private class NNge.Exemplar
extends Instances

Implements Exemplar as used by NNge : parallel axis hyperrectangle.


Field Summary
private  double m_ClassValue
          class of the Exemplar
private  double[] m_MaxBorder
          The max borders of the rectangle for numeric attributes
private  double[] m_MinBorder
          The min borders of the rectangle for numeric attributes
private  int m_NegativeCount
          Number of incorrect prediction for this examplar
private  NNge m_NNge
          The NNge which owns this Exemplar
private  int m_PositiveCount
          Number of correct prediction for this examplar
private  Instance m_PreInst
           
private  double[] m_PreMaxBorder
          the arrays used by preGeneralise
private  double[] m_PreMinBorder
           
private  boolean[][] m_PreRange
           
private  boolean[][] m_Range
          The ranges of the hyperrectangle for nominal attributes
private  NNge.Exemplar next
           
private  NNge.Exemplar nextWithClass
           
private  NNge.Exemplar previous
          List of all the Exemplar
private  NNge.Exemplar previousWithClass
          List of all the Exemplar with the same class
 
Fields inherited from class weka.core.Instances
FILE_EXTENSION, m_Attributes, m_ClassIndex, m_IndicesBuffer, m_Instances, m_RelationName, m_ValueBuffer
 
Constructor Summary
private NNge.Exemplar(NNge nnge, Instances inst, int size, double classV)
          Build a new empty Exemplar
 
Method Summary
private  double attrDistance(Instance inst, int attrIndex)
          Compute the distance between the projection of inst and this Exemplar along the attribute attrIndex.
private  void cancelGeneralisation()
          Cancels a generalisation started with preGeneralise.
private  double classValue()
          Return the class of the Exemplar
private  void generalise(Instance inst)
          Generalise the Exemplar with inst
private  double getMaxBorder(int attrIndex)
          Returns the value of the sup border of the hyperrectangle Returns NaN if the HyperRectangle doesn't have any border for this attribute
private  double getMinBorder(int attrIndex)
          Returns the value of the inf border of the Exemplar.
private  int getNegativeCount()
          Returns the number of negative classifications
private  int getPositiveCount()
          Returns the number of positive classifications
private  boolean holds(Instance inst)
          return true if inst is held by this Exemplar, false otherwise
private  boolean holds(int attrIndex, double value)
          return true if value is inside the Exemplar along the attrIndex attribute.
private  void incrNegativeCount()
          Increment the number of negative Classifications
private  void incrPositiveCount()
          Increment the number of positive Classifications
private  boolean isEmpty()
          Returns true if the Exemplar is empty (i.e. doesn't yield any Instance)
private  boolean overlaps(NNge.Exemplar ex)
          Check if the Examplar overlaps ex
private  void preGeneralise(Instance inst)
          pre-generalise the Exemplar with inst i.e. the boundaries of the Exemplar include inst but the Exemplar still doesn't 'own' inst.
private  void setNegativeCount(int value)
          Set the number of negative classifications
private  void setPositiveCount(int value)
          Set the number of positive classifications
private  double squaredDistance(Instance inst)
          Returns the square of the distance between inst and the Exemplar.
private  java.lang.String toRules()
          Returns a string of the rules induced by this examplar
private  java.lang.String toString2()
          Returns a description of this Exemplar
private  void validateGeneralisation()
          Validates a generalisation started with preGeneralise.
private  double weight()
          Return the weight of the Examplar
 
Methods inherited from class weka.core.Instances
add, attribute, attribute, attributeStats, attributeToDoubleArray, checkForStringAttributes, checkInstance, classAttribute, classIndex, compactify, delete, delete, deleteAttributeAt, deleteStringAttributes, deleteWithMissing, deleteWithMissing, deleteWithMissingClass, enumerateAttributes, enumerateInstances, equalHeaders, firstInstance, getInstance, getInstanceFull, getInstanceSparse, getRandomNumberGenerator, insertAttributeAt, instance, lastInstance, main, meanOrMode, meanOrMode, mergeInstances, numAttributes, numClasses, numDistinctValues, numDistinctValues, numInstances, randomize, readHeader, readInstance, relationName, renameAttribute, renameAttribute, renameAttributeValue, renameAttributeValue, resample, resampleWithWeights, resampleWithWeights, setClass, setClassIndex, setRelationName, sort, sort, stratify, stringFreeStructure, sumOfWeights, test, testCV, toString, toSummaryString, trainCV, trainCV, variance, variance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

previous

private NNge.Exemplar previous
List of all the Exemplar


next

private NNge.Exemplar next

previousWithClass

private NNge.Exemplar previousWithClass
List of all the Exemplar with the same class


nextWithClass

private NNge.Exemplar nextWithClass

m_NNge

private NNge m_NNge
The NNge which owns this Exemplar


m_ClassValue

private double m_ClassValue
class of the Exemplar


m_PositiveCount

private int m_PositiveCount
Number of correct prediction for this examplar


m_NegativeCount

private int m_NegativeCount
Number of incorrect prediction for this examplar


m_MaxBorder

private double[] m_MaxBorder
The max borders of the rectangle for numeric attributes


m_MinBorder

private double[] m_MinBorder
The min borders of the rectangle for numeric attributes


m_Range

private boolean[][] m_Range
The ranges of the hyperrectangle for nominal attributes


m_PreMaxBorder

private double[] m_PreMaxBorder
the arrays used by preGeneralise


m_PreMinBorder

private double[] m_PreMinBorder

m_PreRange

private boolean[][] m_PreRange

m_PreInst

private Instance m_PreInst
Constructor Detail

NNge.Exemplar

private NNge.Exemplar(NNge nnge,
                      Instances inst,
                      int size,
                      double classV)
Build a new empty Exemplar

Parameters:
nnge - the classifier which owns this Exemplar
inst - the instances from which the header information is to be taken
size - the capacity of the Exemplar
classV - the class of the Exemplar
Method Detail

generalise

private void generalise(Instance inst)
                 throws java.lang.Exception
Generalise the Exemplar with inst

Throws:
java.lang.Exception - if either the class of inst is not equal to the class of the Exemplar or inst misses a value.

preGeneralise

private void preGeneralise(Instance inst)
                    throws java.lang.Exception
pre-generalise the Exemplar with inst i.e. the boundaries of the Exemplar include inst but the Exemplar still doesn't 'own' inst. To be complete, the generalisation must be validated with validateGeneralisation. the generalisation can be canceled with cancelGeneralisation.

Throws:
java.lang.Exception - if either the class of inst is not equal to the class of the Exemplar or inst misses a value.

validateGeneralisation

private void validateGeneralisation()
                             throws java.lang.Exception
Validates a generalisation started with preGeneralise. Watch out, preGeneralise must have been called before.

Throws:
java.lang.Exception - is thrown if preGeneralise hasn't been called before

cancelGeneralisation

private void cancelGeneralisation()
                           throws java.lang.Exception
Cancels a generalisation started with preGeneralise. Watch out, preGeneralise must have been called before.

Throws:
java.lang.Exception - is thrown if preGeneralise hasn't been called before

holds

private boolean holds(Instance inst)
return true if inst is held by this Exemplar, false otherwise

Parameters:
inst - an Instance
Returns:
true if inst is held by this hyperrectangle, false otherwise

holds

private boolean holds(int attrIndex,
                      double value)
return true if value is inside the Exemplar along the attrIndex attribute.

Parameters:
attrIndex - the index of an attribute
value - a value along the attrIndexth attribute
Returns:
true if value is inside the Exemplar along the attrIndex attribute.

overlaps

private boolean overlaps(NNge.Exemplar ex)
Check if the Examplar overlaps ex

Parameters:
ex - an Exemplar
Returns:
true if ex is overlapped by the Exemplar
Throws:
java.lang.Exception

attrDistance

private double attrDistance(Instance inst,
                            int attrIndex)
Compute the distance between the projection of inst and this Exemplar along the attribute attrIndex. If inst misses its value along the attribute, the function returns 0.

Parameters:
inst - an instance
attrIndex - the index of the attribute
Returns:
the distance between the projection of inst and this Exemplar along the attribute attrIndex.

squaredDistance

private double squaredDistance(Instance inst)
Returns the square of the distance between inst and the Exemplar.

Parameters:
inst - an instance
Returns:
the squared distance between inst and the Exemplar.

weight

private double weight()
Return the weight of the Examplar

Returns:
the weight of the Examplar.

classValue

private double classValue()
Return the class of the Exemplar

Returns:
the class of this exemplar as a double (weka format)

getMinBorder

private double getMinBorder(int attrIndex)
                     throws java.lang.Exception
Returns the value of the inf border of the Exemplar.

Parameters:
attrIndex - the index of the attribute
Returns:
the value of the inf border for this attribute
Throws:
java.lang.Exception - is thrown either if the attribute is nominal or if the Exemplar is empty

getMaxBorder

private double getMaxBorder(int attrIndex)
                     throws java.lang.Exception
Returns the value of the sup border of the hyperrectangle Returns NaN if the HyperRectangle doesn't have any border for this attribute

Parameters:
attrIndex - the index of the attribute
Returns:
the value of the sup border for this attribute
Throws:
java.lang.Exception - is thrown either if the attribute is nominal or if the Exemplar is empty

getPositiveCount

private int getPositiveCount()
Returns the number of positive classifications

Returns:
the number of positive classifications

getNegativeCount

private int getNegativeCount()
Returns the number of negative classifications

Returns:
the number of negative classifications

setPositiveCount

private void setPositiveCount(int value)
Set the number of positive classifications

Parameters:
value - an integer value (greater than 0 is wise...)

setNegativeCount

private void setNegativeCount(int value)
Set the number of negative classifications

Parameters:
value - an integer value

incrPositiveCount

private void incrPositiveCount()
Increment the number of positive Classifications


incrNegativeCount

private void incrNegativeCount()
Increment the number of negative Classifications


isEmpty

private boolean isEmpty()
Returns true if the Exemplar is empty (i.e. doesn't yield any Instance)

Returns:
true if the Exemplar is empty, false otherwise

toString2

private java.lang.String toString2()
Returns a description of this Exemplar

Returns:
A string that describes this Exemplar

toRules

private java.lang.String toRules()
Returns a string of the rules induced by this examplar

Returns:
a string of the rules induced by this examplar