Class Partition

java.lang.Object
  |
  +--Partition
Direct Known Subclasses:
Chromosome

public class Partition
extends java.lang.Object

Partition


Field Summary
static int CF_DIV
           
static int CF_POW
           
static int CF_PROD
           
static int CF_SYM_DIFF
           
protected  boolean cfIsValid
           
protected  java.util.Hashtable classCard
           
protected  java.util.Hashtable classCode
           
protected  java.util.Hashtable classFitness
           
protected  int classFitnessType
           
protected  double fitness
           
protected  int maxNoClasses
           
protected  int size
           
protected  int[] v
           
 
Method Summary
 void adjust(java.util.Random rand)
          adjusts this Partition to have exactly getMaxNoClasses() classes
 void computeFitness(java.util.Hashtable[] intersectMap, Partition[] c, int NPART, int entropyMeasure, int fitnessMeasure, double[] wTargetCondOnDB, double[] wDBCondOnTarget, double[] weight)
          computes the fitness of this Partition with respect to its intersection to NPART partitions in c, available in intersectMap, according to the entropy measure and distance measure
 void computeFitness(Partition[] c, int NPART, int entropyMeasure, int fitnessMeasure, double[] wTargetCondOnDB, double[] wDBCondOnTarget, double[] weight)
          computes the fitness of this Partition with respect to the partitions in collection c, according to the entropy measure and distance measure
static void computeInfoIntersections(Partition[] c, int NPART, int entropyMeasure, java.util.Vector v)
          fills the vector v with a Double representing the value of the entropy of the partition determined by the intersection of all NPART partitions in the collection c and with an Integer representing the number of classes of the intersection partition
static void computeIntersections(Partition[] c1, int NPART1, Partition[] c2, int NPART2, java.util.Hashtable[][] intersectMap)
          computes intersections between the classes of partitions in collection c1 and classes of the partitions in collection c2
static void computeIntersections(Partition p, Partition[] c, int NPART, java.util.Hashtable[] intersectMap)
          computes intersections between the classes of partition p and classes of the partitions in collection c
 void computeSilhouettes(double[] silhouettes, int[] neighbors, Partition[] c, int NPART)
          fills the array silhouettes of dimension 'size' with the silhoutte coefficients, computed with respect to the classes in this Partition and with respect to the values of the NPART partitions in collection c; this Partition should have at least 2 classes; neighbors will contain for each rowid the class number of the closest class
 double distSymDiff(Partition c)
           
 double entropy(int entropyMeasure)
           
 double entropyIntersect(Partition p, int entropyMeasure)
           
static double estimateWeights(Partition[] db, int NPART, double sampleDBPct, int entropyMeasure, double[] wTargetCondOnDB, double[] wDBCondOnTarget, double[] weight, java.util.Random rand)
          estimates the degree in which the other partitions in db influences the target partition; the target partition should be the last partition in db; sampleDBPct specifies the percent of the database to be sampled; sets wTargetCondonDB[i] to H(db[i]|db[target]) and sets the wDBCondOnTarget[i] to H(db[target]|db[i]); sets weight[i] to wTargetCondOnDB[i]+wDBCondOnTarget[i]
 int get(int rowid)
           
 void getAM(java.util.Hashtable[] am)
          fills an array of Hashtable objects, am, with the array representation of the partition; in this array each class corresponds to an index in the array; the contents of the array at that index is a Hashtable with the rowids where the class appears in the partition
 int getClassCard(int c)
           
 java.lang.Integer getClassCode(java.lang.String classOrig)
           
 java.lang.String getClassesAndCardinalities()
          returns a String containing a list of classes of this Partition and their cardinalities
 double getClassFitness(int c)
           
 int getClassFitnessType()
           
 double getClassifRate(Partition target)
           
 java.util.ArrayList getClassIntersections(Partition target)
           
 double getFitness()
           
 int getMaxNoClasses()
           
 int getNoClasses()
           
 int getSize()
           
 boolean hasClassCode(java.lang.String classOrig)
           
 void init(java.util.Random rand)
          randomly initializes this Partition
 boolean isEqual(Partition p)
           
static void main(java.lang.String[] args)
           
 void plotSilhouettes(double[] silhouettes, int[] neighbors)
          plots a graphical representation of the silhouettes; classes are plotted in order and the elements in the classes are plotted in decreasing order of their silhouette
 void plotSilhouettes(double[] silhouettes, int[] neighbors, java.lang.StringBuffer output)
          appends to output a graphical representation of the silhouettes; classes are plotted in order and the elements in the classes are plotted in decreasing order of their silhouette
protected  void print()
          prints this Partition as an array of integers
protected  void print(java.lang.StringBuffer output)
          appends contents of this Partition as an array of integers to output
 void printAM()
          prints this Partition as an array of a collection of rowids
 void printClassCardinalities()
          prints cardinalities of the classes of this Partition
 void printClassCardinalities(java.lang.StringBuffer output)
          appends cardinalities of the classes of this Partition to the output
 void printClassFitness()
          prints the class fitness values
 void printClassInfo()
          prints information about the classes of this Partition
 void printInfo(Partition[] db, int NPART, double[] wTargetCondOnDB, double[] wDBCondOnTarget, double[] weight, int entropyMeasure, int fitnessMeasure, java.lang.String s)
          prints information about this Partition
 void printInfo(Partition[] db, int NPART, double[] wTargetCondOnDB, double[] wDBCondOnTarget, double[] weight, int entropyMeasure, int fitnessMeasure, java.lang.String s, java.lang.StringBuffer output)
          appends information about this Partition to output
static void printIntersections(java.util.Hashtable[] intersectMap, int nPart)
          prints the intersection between classes of one partition and other nPart partitions
 void set(int rowid, int c)
          sets rowid to belong to class c, updates the class cardinality of the new and old class to whom rowid belongs
 void set(Partition p)
          sets the values of this Partition equal to the one from the parameter
 void setAM(java.util.Hashtable[] am)
          sets this Partition according to the groupings in the array of Hashtables am that contains am.length Hashtables
 void setClassCode(java.lang.String classOrig, java.lang.Integer code)
          sets an Integer encoding code for the class classOrig
 void setClassFitness(int c, double value)
          sets the fitness of class c to value
 void setFitness(double f)
          sets the fitness of this Partition to value f
 void setSize(int size)
          resets the size of this partition to a smaller value size
 double sumDistSymDiff(Partition[] c, int NPART)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classFitnessType

protected int classFitnessType

v

protected int[] v

size

protected int size

maxNoClasses

protected int maxNoClasses

classCard

protected java.util.Hashtable classCard

classCode

protected java.util.Hashtable classCode

classFitness

protected java.util.Hashtable classFitness

cfIsValid

protected boolean cfIsValid

fitness

protected double fitness

CF_SYM_DIFF

public static final int CF_SYM_DIFF
See Also:
Constant Field Values

CF_PROD

public static final int CF_PROD
See Also:
Constant Field Values

CF_DIV

public static final int CF_DIV
See Also:
Constant Field Values

CF_POW

public static final int CF_POW
See Also:
Constant Field Values
Method Detail

set

public void set(int rowid,
                int c)
sets rowid to belong to class c, updates the class cardinality of the new and old class to whom rowid belongs


get

public int get(int rowid)
Returns:
the class of rowid

hasClassCode

public boolean hasClassCode(java.lang.String classOrig)
Returns:
true if the class classOrig has already a numeric code

getClassCode

public java.lang.Integer getClassCode(java.lang.String classOrig)
Returns:
an Integer encoding associated with the class classOrig

setClassCode

public void setClassCode(java.lang.String classOrig,
                         java.lang.Integer code)
sets an Integer encoding code for the class classOrig


getMaxNoClasses

public int getMaxNoClasses()
Returns:
the maximum number of classes

getNoClasses

public int getNoClasses()
Returns:
the actual number of classes

printClassInfo

public void printClassInfo()
prints information about the classes of this Partition


getClassesAndCardinalities

public java.lang.String getClassesAndCardinalities()
returns a String containing a list of classes of this Partition and their cardinalities


printClassCardinalities

public void printClassCardinalities()
prints cardinalities of the classes of this Partition


printClassCardinalities

public void printClassCardinalities(java.lang.StringBuffer output)
appends cardinalities of the classes of this Partition to the output


printClassFitness

public void printClassFitness()
prints the class fitness values


getSize

public int getSize()
Returns:
the size of this Partition

setSize

public void setSize(int size)
resets the size of this partition to a smaller value size


init

public void init(java.util.Random rand)
randomly initializes this Partition

Parameters:
rand - random number generator

adjust

public void adjust(java.util.Random rand)
adjusts this Partition to have exactly getMaxNoClasses() classes

Parameters:
rand - a random number generator object

getAM

public void getAM(java.util.Hashtable[] am)
fills an array of Hashtable objects, am, with the array representation of the partition; in this array each class corresponds to an index in the array; the contents of the array at that index is a Hashtable with the rowids where the class appears in the partition


setAM

public void setAM(java.util.Hashtable[] am)
sets this Partition according to the groupings in the array of Hashtables am that contains am.length Hashtables


print

protected void print()
prints this Partition as an array of integers


print

protected void print(java.lang.StringBuffer output)
appends contents of this Partition as an array of integers to output


printAM

public void printAM()
prints this Partition as an array of a collection of rowids


entropy

public double entropy(int entropyMeasure)
Returns:
the entropy of this partition computed with entropyMeasure

isEqual

public boolean isEqual(Partition p)
Returns:
true if this Partition is equal to the one received as argument, false otherwise

set

public void set(Partition p)
sets the values of this Partition equal to the one from the parameter


getClassCard

public int getClassCard(int c)
Returns:
the cardinality of class c

getClassFitness

public double getClassFitness(int c)
Returns:
the fitness of class c

setClassFitness

public void setClassFitness(int c,
                            double value)
sets the fitness of class c to value


getFitness

public double getFitness()
Returns:
fitness of this Partition

setFitness

public void setFitness(double f)
sets the fitness of this Partition to value f


getClassFitnessType

public int getClassFitnessType()
Returns:
the fitness type of the classes

computeIntersections

public static void computeIntersections(Partition[] c1,
                                        int NPART1,
                                        Partition[] c2,
                                        int NPART2,
                                        java.util.Hashtable[][] intersectMap)
computes intersections between the classes of partitions in collection c1 and classes of the partitions in collection c2

Parameters:
NPART1 - represents the number of partitions in c1
NPART2 - represents the number of partitions in c2
intersectMap - stores in intersectMap[i][j]: >; intersectMap[i][j] is a map for intersections between partitions c1[i] and c2[j]; intersectMap[i][j]:key corresponds to each distinct value in c1[i](C_s); intersectMap[i][j]:value corresponds to a map with intersections between c2[j][t] and c1[i][s] (B_t x C_s); intersectMap[i][j] = >

computeIntersections

public static void computeIntersections(Partition p,
                                        Partition[] c,
                                        int NPART,
                                        java.util.Hashtable[] intersectMap)
computes intersections between the classes of partition p and classes of the partitions in collection c

Parameters:
NPART - represents the number of partitions in c

printIntersections

public static void printIntersections(java.util.Hashtable[] intersectMap,
                                      int nPart)
prints the intersection between classes of one partition and other nPart partitions


entropyIntersect

public double entropyIntersect(Partition p,
                               int entropyMeasure)
Returns:
entropy of the partition resulting from the intersection of this Partition with the one received as argument, computed with entropyMeasure

computeInfoIntersections

public static void computeInfoIntersections(Partition[] c,
                                            int NPART,
                                            int entropyMeasure,
                                            java.util.Vector v)
fills the vector v with a Double representing the value of the entropy of the partition determined by the intersection of all NPART partitions in the collection c and with an Integer representing the number of classes of the intersection partition


computeFitness

public void computeFitness(java.util.Hashtable[] intersectMap,
                           Partition[] c,
                           int NPART,
                           int entropyMeasure,
                           int fitnessMeasure,
                           double[] wTargetCondOnDB,
                           double[] wDBCondOnTarget,
                           double[] weight)
computes the fitness of this Partition with respect to its intersection to NPART partitions in c, available in intersectMap, according to the entropy measure and distance measure


computeFitness

public void computeFitness(Partition[] c,
                           int NPART,
                           int entropyMeasure,
                           int fitnessMeasure,
                           double[] wTargetCondOnDB,
                           double[] wDBCondOnTarget,
                           double[] weight)
computes the fitness of this Partition with respect to the partitions in collection c, according to the entropy measure and distance measure


estimateWeights

public static double estimateWeights(Partition[] db,
                                     int NPART,
                                     double sampleDBPct,
                                     int entropyMeasure,
                                     double[] wTargetCondOnDB,
                                     double[] wDBCondOnTarget,
                                     double[] weight,
                                     java.util.Random rand)
estimates the degree in which the other partitions in db influences the target partition; the target partition should be the last partition in db; sampleDBPct specifies the percent of the database to be sampled; sets wTargetCondonDB[i] to H(db[i]|db[target]) and sets the wDBCondOnTarget[i] to H(db[target]|db[i]); sets weight[i] to wTargetCondOnDB[i]+wDBCondOnTarget[i]

Returns:
the entropy of the partition sampled from the database

distSymDiff

public double distSymDiff(Partition c)
Returns:
the symmetrical difference between the classes of the current partition and the one received as argument

sumDistSymDiff

public double sumDistSymDiff(Partition[] c,
                             int NPART)
Returns:
Sum distSymDiff(p), for all p in the collection c

computeSilhouettes

public void computeSilhouettes(double[] silhouettes,
                               int[] neighbors,
                               Partition[] c,
                               int NPART)
fills the array silhouettes of dimension 'size' with the silhoutte coefficients, computed with respect to the classes in this Partition and with respect to the values of the NPART partitions in collection c; this Partition should have at least 2 classes; neighbors will contain for each rowid the class number of the closest class


plotSilhouettes

public void plotSilhouettes(double[] silhouettes,
                            int[] neighbors)
plots a graphical representation of the silhouettes; classes are plotted in order and the elements in the classes are plotted in decreasing order of their silhouette


plotSilhouettes

public void plotSilhouettes(double[] silhouettes,
                            int[] neighbors,
                            java.lang.StringBuffer output)
appends to output a graphical representation of the silhouettes; classes are plotted in order and the elements in the classes are plotted in decreasing order of their silhouette


printInfo

public void printInfo(Partition[] db,
                      int NPART,
                      double[] wTargetCondOnDB,
                      double[] wDBCondOnTarget,
                      double[] weight,
                      int entropyMeasure,
                      int fitnessMeasure,
                      java.lang.String s)
prints information about this Partition


printInfo

public void printInfo(Partition[] db,
                      int NPART,
                      double[] wTargetCondOnDB,
                      double[] wDBCondOnTarget,
                      double[] weight,
                      int entropyMeasure,
                      int fitnessMeasure,
                      java.lang.String s,
                      java.lang.StringBuffer output)
appends information about this Partition to output


getClassIntersections

public java.util.ArrayList getClassIntersections(Partition target)
Returns:
and ArrayList of ArrayList elements containing a string representing the class of target and a String representing intersections with the classes of this Partition

getClassifRate

public double getClassifRate(Partition target)
Returns:
the percent of rowids classified in the same way as in the target partition

main

public static void main(java.lang.String[] args)