id3
Class LeafCategorizer

java.lang.Object
  |
  +--shared.Globals
        |
        +--shared.Categorizer
              |
              +--id3.NodeCategorizer
                    |
                    +--id3.LeafCategorizer

public class LeafCategorizer
extends NodeCategorizer

NodeCategorizer for categorizers that don't need to ask other categorizers for help scoring (i.e. leaves in the decision process). Since any categorizer can sit at a leaf in a decision tree / graph, this class serves as a wrapper for any Categorizer that doesn't care about whether or not it sits in a graph. This class is a pure wrapper to the inner categorizer. That is, it doesn't maintain any information at all except for the reference to the wrapped categorizer. The OK function should check that none of the local variables ever change from their dummy variables.


Fields inherited from class shared.Categorizer
CATEGORIZER_ID_BASE, CLASS_ATTR_CATEGORIZER, CLASS_ATTR_EQ_CATEGORIZER, CLASS_ATTR_SUBSET_CATEGORIZER, CLASS_BAD_CATEGORIZER, CLASS_BAGGING_CATEGORIZER, CLASS_CASCADE_CATEGORIZER, CLASS_CLUSTER_CATEGORIZER, CLASS_CONST_CATEGORIZER, CLASS_CONSTRUCT_CATEGORIZER, CLASS_DISC_CATEGORIZER, CLASS_DISC_NODE_CATEGORIZER, CLASS_DTREE_CATEGORIZER, CLASS_IB_CATEGORIZER, CLASS_LAZYDT_CATEGORIZER, CLASS_LEAF_CATEGORIZER, CLASS_LINDISCR_CATEGORIZER, CLASS_MAJORITY_CATEGORIZER, CLASS_MULTI_SPLIT_CATEGORIZER, CLASS_MULTITHRESH_CATEGORIZER, CLASS_NB_CATEGORIZER, CLASS_ODT_CATEGORIZER, CLASS_ONE_R_CATEGORIZER, CLASS_OPTION_CATEGORIZER, CLASS_PROJECT_CATEGORIZER, CLASS_RDG_CATEGORIZER, CLASS_STACKING_CATEGORIZER, CLASS_TABLE_CATEGORIZER, CLASS_THRESHOLD_CATEGORIZER, logOptions
 
Fields inherited from class shared.Globals
badCategorizer, CONFIDENCE_INTERVAL_Z, DBG, DEFAULT_DATA_EXT, DEFAULT_EPSILON, DEFAULT_EVAL_LIMIT, DEFAULT_LAMBDA, DEFAULT_MAX_EVALS, DEFAULT_MAX_STALE, DEFAULT_MIN_EXP_EVALS, DEFAULT_NAMES_EXT, DEFAULT_SAS_SEED, DEFAULT_SEARCH_METHOD, DEFAULT_SHOW_TEST_SET_PERF, DEFAULT_TEST_EXT, DISPLAY_NAMES, EMPTY_STRING, FIRST_CATEGORY_VAL, FIRST_NOMINAL_VAL, LEFT_NODE, MAX_NUM_CATEGORIES, Mcerr, Mcout, optionServer, optionsFileName, REAL_MAX, RIGHT_NODE, SHOW_TEST_SET_PERF_HELP, SINGLE_QUOTE, STORED_REAL_MAX, TS, UNDEFINED_INT, UNDEFINED_REAL, UNDEFINED_VARIANCE, UNKNOWN_AUG_CATEGORY, UNKNOWN_CATEGORY_VAL, UNKNOWN_NODE, UNKNOWN_NOMINAL_VAL, UNKNOWN_STORED_REAL_VAL, UNKNOWN_VAL_STR
 
Constructor Summary
LeafCategorizer(Categorizer aCategorizer)
          Constructor.
 
Method Summary
 AugCategory branch(Instance inst)
          Returns the category for the given Instance.
 void build_distr(InstanceList instList)
          builds an Instance distribution from the InstanceList.
 int class_id()
          Deprecated. This method should be replaced with Java's instanceof operator.
 java.lang.Object clone()
          Clone function.
 java.lang.String description()
          Returns the description of the Categorizer stored in this LeafCategorizer.
 void display_struct(java.io.BufferedWriter stream, DisplayPref pref)
          Displays the structure of the Categorizer stored in this LeafCategorizer.
 Categorizer get_categorizer()
          Returns the Categorizer stored in this LeafCategorizer.
 int num_categories()
          Returns the number of categories for the categorizer stored in this LeafCategorizer.
 CatDist score(Instance inst)
          Scores the given Instance using the categorizer stored in this LeafCategorizer.
 CatDist score(Instance inst, boolean addLoss)
          Scores the given Instance using the categorizer stored in this LeafCategorizer.
 void set_description(java.lang.String val)
          Sets the description of this LeafCategorizer to the given value.
 void set_distr(double[] val)
          Sets the distribution to the given values.
 void set_used_attr(boolean[] used)
          Sets which attributes have been used for the attributes in the Categorizer stored in this LeafCategorizer.
 boolean supports_scoring()
          Returns whether this Categorizer subclass supports scoring.
 double total_weight()
          Returns the total weight of instances that reach this LeafCategorizer.
 
Methods inherited from class id3.NodeCategorizer
add_instance_loss, categorize, distribute_instances, get_child_categorizer, get_child_categorizer, get_graph, get_loss, get_node, in_graph, reset_node_loss, set_graph_and_node, split_instance_list, stop, toString, update_loss
 
Methods inherited from class shared.Categorizer
get_distr, get_log_level, get_log_options, get_log_stream, get_schema, has_distr, set_log_level, set_log_options, set_log_prefixes, set_log_stream, set_original_distr
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LeafCategorizer

public LeafCategorizer(Categorizer aCategorizer)
Constructor.
Parameters:
aCategorizer - The Categorizer that will be stored in this LeafCategorizer.
Method Detail

class_id

public int class_id()
Deprecated. This method should be replaced with Java's instanceof operator.

Returns the class id of this of this categorizer.
Returns:
Integer assigned to this inducer.

branch

public AugCategory branch(Instance inst)
Returns the category for the given Instance. Leaf categorizers have no children, so this function aborts.
Overrides:
branch in class NodeCategorizer
Parameters:
inst - The instance to be checked.
Returns:
Always returns the category "bad branch" with the category number 0.

get_categorizer

public Categorizer get_categorizer()
Returns the Categorizer stored in this LeafCategorizer.
Returns:
The Categorizer stored in this LeafCategorizer.

clone

public java.lang.Object clone()
Clone function.
Overrides:
clone in class Categorizer
Returns:
The clone of this object.

set_used_attr

public void set_used_attr(boolean[] used)
Sets which attributes have been used for the attributes in the Categorizer stored in this LeafCategorizer.
Overrides:
set_used_attr in class Categorizer
Parameters:
used - The attributes used. TRUE indicates that attribute is used, FALSE otherwise.

display_struct

public void display_struct(java.io.BufferedWriter stream,
                           DisplayPref pref)
Displays the structure of the Categorizer stored in this LeafCategorizer.
Overrides:
display_struct in class Categorizer
Parameters:
stream - The BufferedWriter to which this LeafCategorizer will be displayed.
pref - The preferences for display.

num_categories

public int num_categories()
Returns the number of categories for the categorizer stored in this LeafCategorizer.
Overrides:
num_categories in class Categorizer
Returns:
The number of categories for the categorizer stored in this LeafCategorizer.

description

public java.lang.String description()
Returns the description of the Categorizer stored in this LeafCategorizer.
Overrides:
description in class Categorizer
Returns:
The description of the Categorizer stored in this LeafCategorizer.

score

public CatDist score(Instance inst)
Scores the given Instance using the categorizer stored in this LeafCategorizer.
Overrides:
score in class NodeCategorizer
Parameters:
inst - The Instance given for categorization.
Returns:
The category distribution of the supplied instance.

score

public CatDist score(Instance inst,
                     boolean addLoss)
Scores the given Instance using the categorizer stored in this LeafCategorizer.
Overrides:
score in class NodeCategorizer
Parameters:
inst - The Instance given for categorization.
addLoss - TRUE if Instance loss is to be added, FALSE otherwise.
Returns:
The category distribution of the supplied instance.

build_distr

public void build_distr(InstanceList instList)
builds an Instance distribution from the InstanceList.
Overrides:
build_distr in class Categorizer
Parameters:
instList - The list of Instances from which a distribution is to be built.

set_description

public void set_description(java.lang.String val)
Sets the description of this LeafCategorizer to the given value.
Overrides:
set_description in class Categorizer
Parameters:
val - The new description for this Node Categorizer.

supports_scoring

public boolean supports_scoring()
Returns whether this Categorizer subclass supports scoring.
Overrides:
supports_scoring in class NodeCategorizer
Returns:
TRUE.

set_distr

public void set_distr(double[] val)
Sets the distribution to the given values.
Overrides:
set_distr in class Categorizer
Parameters:
val - An array containing the new distribution values.

total_weight

public double total_weight()
Returns the total weight of instances that reach this LeafCategorizer.
Overrides:
total_weight in class Categorizer
Returns:
The total weight of instances that reach this LeafCategorizer.