org.apache.mahout.ga.watchmaker.cd
Class CDRule

java.lang.Object
  extended by org.apache.mahout.ga.watchmaker.cd.CDRule
All Implemented Interfaces:
Rule

public final class CDRule
extends Object
implements Rule

Binary classification rule of the form:

 if (condition1 && condition2 && ... ) then
   class = 1
 else
   class = 0
 
where conditioni = (wi): attributi oi vi


Constructor Summary
CDRule(CDRule ind)
          Copy Constructor
CDRule(double threshold)
           
CDRule(double threshold, Random rng)
          Random rule.
 
Method Summary
static boolean areGenesEqual(CDRule rule1, CDRule rule2, int index)
          Compares a given gene between two rules
 boolean areGenesEqual(int index1, int index2)
          Compares two genes from this Rule
static int attributeIndex(int condInd)
          Makes sure that the label is not handled by any condition.
 int classify(DataLine dl)
          if all the active conditions are met returns 1, else returns 0.
 boolean equals(Object obj)
           
 int getNbConditions()
           
 boolean getO(int index)
          operator
 double getV(int index)
           
 double getW(int index)
           
 int hashCode()
           
 void setO(int index, boolean o)
          set the operator
 void setV(int index, double v)
           
 void setW(int index, double w)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CDRule

public CDRule(double threshold)
Parameters:
threshold - condition activation threshold

CDRule

public CDRule(double threshold,
              Random rng)
Random rule.


CDRule

public CDRule(CDRule ind)
Copy Constructor

Method Detail

classify

public int classify(DataLine dl)
if all the active conditions are met returns 1, else returns 0.

Specified by:
classify in interface Rule
Parameters:
dl - dataLine to classify
Returns:
class of dl

attributeIndex

public static int attributeIndex(int condInd)
Makes sure that the label is not handled by any condition.

Parameters:
condInd - condition index
Returns:
attribute index

toString

public String toString()
Overrides:
toString in class Object

getNbConditions

public int getNbConditions()

getW

public double getW(int index)

setW

public void setW(int index,
                 double w)

getO

public boolean getO(int index)
operator

Returns:
true if '>='; false if '<'

setO

public void setO(int index,
                 boolean o)
set the operator

Parameters:
o - true if '>='; false if '<'

getV

public double getV(int index)

setV

public void setV(int index,
                 double v)

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

areGenesEqual

public static boolean areGenesEqual(CDRule rule1,
                                    CDRule rule2,
                                    int index)
Compares a given gene between two rules

Parameters:
index - gene index
Returns:
true if the gene is the same

areGenesEqual

public boolean areGenesEqual(int index1,
                             int index2)
Compares two genes from this Rule

Parameters:
index1 - first gene index
index2 - second gene index
Returns:
if the genes are equal


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.