weka.roughset
Class MDCutPoints

java.lang.Object
  |
  +--weka.roughset.MDCutPoints

public class MDCutPoints
extends Object

MDCutPoints represents a set of cuts on numerical attributes, used in weka.filters.DynamicReductDiscretize and weka.filters.RSDiscretize.

Version:
1.0
Author:
Ola Leifler

Constructor Summary
MDCutPoints()
          Dummy constructor.
MDCutPoints(Instances i)
          Creates a new MDCutPoints instance by sorting the instances on each successive numerical attribute and creating SortedClasses-objects each time, representing the instances.
MDCutPoints(Reduct r)
           
 
Method Summary
 void addCut(CutPoint cut)
          Add a new cutPoint to the set.
 boolean attributeDiscretized(Attribute a)
          Is attribute a discretized?
 Instances binaryInstances(Instances insts)
          Create a new dataset where each cutpoint becomes a binary attribute.
 boolean equals(Object o)
           
 void fillNonDiscretized(Instances inst)
          Add all possible cuts for the nondiscretized attributes in the set
 CutPoint getCut(int i)
           
 CutPoint getMaxCut()
          Get the cutpoint that discerns the most objects.
 CutPoint getMaxCut(Attribute a)
          Get the cut on attribute athat discerns the most pairs of objects modulo their decision values.
 CutPoint getMaxCut(SortedClasses classes)
           
 MDCutPoints getSubset(Attributes a)
          Translate a set of attributes into the corresponding set of cuts by this method.
static void main(String[] args)
          Method for testing the MDCutPoints
 boolean removeCut(CutPoint c)
           
 int size()
           
 double[][] toDoubleArray(Instances insts)
          We use the representation of cutpoints that weka.filters.Discretizefilter uses so that we can steal the convertInstance(Instance i)-method from there in our own classes that use this class as the representation of cutpoints.
 String toInfoString()
          Outputs not only the attributes and values of the cuts, but also discernibility-related information
 Reduct toReduct(Instances insts)
          Translate the cuts to a Reduct which is simply a set of attributes associated with a new table of binary values.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MDCutPoints

public MDCutPoints(Reduct r)

MDCutPoints

public MDCutPoints(Instances i)
            throws Exception
Creates a new MDCutPoints instance by sorting the instances on each successive numerical attribute and creating SortedClasses-objects each time, representing the instances. Each class represents a set of objects that all have the same value on the current numerical attribute. Those sets are given as arguments for the constructors of each CutPoint that is constructed.

Parameters:
i - an Instances value
Throws:
Exception - if an error occurs

MDCutPoints

public MDCutPoints()
Dummy constructor. Creates a new empty MDCutPoints instance.

Method Detail

addCut

public void addCut(CutPoint cut)
            throws Exception
Add a new cutPoint to the set.

Parameters:
cut - a CutPoint value
Throws:
Exception - if the argument is null.

getCut

public CutPoint getCut(int i)

removeCut

public boolean removeCut(CutPoint c)

getMaxCut

public CutPoint getMaxCut(Attribute a)
Get the cut on attribute athat discerns the most pairs of objects modulo their decision values. Discernibility is computed by each CutPoint.

Parameters:
a - an Attribute value
Returns:
a CutPoint value

getMaxCut

public CutPoint getMaxCut()
Get the cutpoint that discerns the most objects.

Returns:
a CutPoint value

getMaxCut

public CutPoint getMaxCut(SortedClasses classes)
                   throws NullPointerException
NullPointerException

attributeDiscretized

public boolean attributeDiscretized(Attribute a)
Is attribute a discretized?

Parameters:
a - an Attribute value
Returns:
a boolean value

fillNonDiscretized

public void fillNonDiscretized(Instances inst)
Add all possible cuts for the nondiscretized attributes in the set

Parameters:
inst - an Instances value

binaryInstances

public Instances binaryInstances(Instances insts)

Create a new dataset where each cutpoint becomes a binary attribute. Encode "less than" as 0 and "greater than or equal" as 1 (see toAttributes() below). Then, insert the data from the old table into the new one. We will want to use this table for calculating a reduct, which will correspond to a set of cuts in the old table.

Parameters:
insts - an Instances value
Returns:
an Instances value

toReduct

public Reduct toReduct(Instances insts)
Translate the cuts to a Reduct which is simply a set of attributes associated with a new table of binary values.

Parameters:
insts - an Instances value
Returns:
a Reduct value

getSubset

public MDCutPoints getSubset(Attributes a)
                      throws Exception
Translate a set of attributes into the corresponding set of cuts by this method. Only matches the names of the attributes to the toString()-values of the cutspoints in this set and keeps those that are matched to an attribute name.

Parameters:
a - an Attributes value
Returns:
a MDCutPoints value
Throws:
Exception - if an error occurs

toDoubleArray

public double[][] toDoubleArray(Instances insts)
We use the representation of cutpoints that weka.filters.Discretizefilter uses so that we can steal the convertInstance(Instance i)-method from there in our own classes that use this class as the representation of cutpoints.

Parameters:
insts - an Instances value
Returns:
a double[][] value

toString

public String toString()
Overrides:
toString in class Object

toInfoString

public String toInfoString()
Outputs not only the attributes and values of the cuts, but also discernibility-related information

Returns:
a String value

equals

public boolean equals(Object o)
Overrides:
equals in class Object

size

public int size()

main

public static void main(String[] args)
Method for testing the MDCutPoints

Parameters:
args - a String[] value