shared
Class ConstCategorizer

java.lang.Object
  |
  +--shared.Globals
        |
        +--shared.Categorizer
              |
              +--shared.ConstCategorizer

public class ConstCategorizer
extends Categorizer

ConstCategorizer always gives the same category. Categories must be greater than UNKNOWN_CATEGORY_VAL. For safety reasons, an upper bound of MAX_NUM_CATEGORIES is exists.


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
ConstCategorizer(java.lang.String dscr, AugCategory augCat, Schema sch)
          This constructor builds the "all the eggs in one basket" type of const categorizer.
ConstCategorizer(java.lang.String dscr, CatDist pDist, Schema sch)
          This constructor allows full specification of the prediction distribution for this categorizer.
 
Method Summary
 AugCategory categorize(Instance i)
          Categorizes the given Instance.
 int class_id()
          Deprecated. This method should be replaced with Java's instanceof operator.
 java.lang.Object clone()
          Clones this ConstCategorizer.
 void display_struct(java.io.BufferedWriter stream, DisplayPref dp)
          Prints a readable representation of the ConstCategorizer to the given stream.
 CatDist get_cat_dist()
          Returns the distribution of predicted categories.
 AugCategory get_category()
          Returns the category that all Instances will be classified as.
 CatDist score(Instance i)
          Returns the CatDist containing the weighted distribution score for the given Instance.
 void set_used_attr(boolean[] used)
          Sets which attributes have been used in this ConstCategorizer.
 
Methods inherited from class shared.Categorizer
build_distr, description, get_distr, get_log_level, get_log_options, get_log_stream, get_schema, has_distr, num_categories, set_description, set_distr, set_log_level, set_log_options, set_log_prefixes, set_log_stream, set_original_distr, supports_scoring, total_weight
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstCategorizer

public ConstCategorizer(java.lang.String dscr,
                        AugCategory augCat,
                        Schema sch)
This constructor builds the "all the eggs in one basket" type of const categorizer. It will always predict the given category, but its prediction distribution will give 100% of the weight to this choice.
Parameters:
dscr - Description of this ConstCategorizer.
augCat - Category that all Instances will be categorized as.
sch - The Schema of attributes and labels for this Categorizer.

ConstCategorizer

public ConstCategorizer(java.lang.String dscr,
                        CatDist pDist,
                        Schema sch)
This constructor allows full specification of the prediction distribution for this categorizer. The schema in the prediction distribution MUST match the schema being used to build the categorizer.
Parameters:
dscr - Description of this ConstCategorizer.
pDist - The distribution of predicted categories specified.
sch - The Schema of attributes and labels for this Categorizer.
Method Detail

categorize

public AugCategory categorize(Instance i)
Categorizes the given Instance.
Overrides:
categorize in class Categorizer
Parameters:
i - The Instance to be categorized.
Returns:
The category this Instance is labelled as.

score

public CatDist score(Instance i)
Returns the CatDist containing the weighted distribution score for the given Instance. Displays an error message for the Categorizer Class.
Overrides:
score in class Categorizer
Parameters:
i - The Instance to be scored.
Returns:
The CatDist containing the weighted distribution.

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 Categorizer.

get_category

public AugCategory get_category()
Returns the category that all Instances will be classified as.
Returns:
The category that all Instances will be classified as.

get_cat_dist

public CatDist get_cat_dist()
Returns the distribution of predicted categories.
Returns:
The distribution of predicted categories.

clone

public java.lang.Object clone()
Clones this ConstCategorizer.
Overrides:
clone in class Categorizer
Returns:
The clone of this Categorizer.

display_struct

public void display_struct(java.io.BufferedWriter stream,
                           DisplayPref dp)
Prints a readable representation of the ConstCategorizer to the given stream.
Overrides:
display_struct in class Categorizer
Parameters:
stream - The Buffered Writer to which information will be displayed.
dp - The preferences for Display.

set_used_attr

public void set_used_attr(boolean[] used)
Sets which attributes have been used in this ConstCategorizer.
Overrides:
set_used_attr in class Categorizer
Parameters:
used - The attributes used. TRUE if the corresponding attribute has been used.