shared
Class Schema

java.lang.Object
  |
  +--shared.Schema

public class Schema
extends java.lang.Object

Schema defines the attribute information. Most effort was directed at labelled instances for supervised learning, and on discrete attributes.


Inner Class Summary
 class Schema.StringNum
          String to Double transformation device.
 
Constructor Summary
Schema(java.util.LinkedList attrInfos)
          Constructor.
Schema(java.util.LinkedList attrInfos, AttrInfo lInfo)
          Constructor.
Schema(Schema source)
          Copy Constructor.
 
Method Summary
 AttrInfo attr_info(int num)
          Returns the AttrInfo object containing the specified attribute's information.
 java.lang.String attr_name(int attrNum)
          Returns the name of the specified attribute.
 java.lang.String category_to_label_string(int cat)
          Returns the name of the specified category label.
 void display_names(java.io.Writer stream, boolean protectChars, java.lang.String header)
          Displays the names file associated with the instances.
 void establish_loss_matrix()
          Allocates the loss matrix for this Schema object.
static int findindexofmin(Schema.StringNum[] sn, int start)
          Finds the index of the minimum value in an array of StringNum values.
 double[][] get_loss_matrix()
          Returns the loss matrix for this Schema object.
 boolean has_loss_matrix()
          Checks if this Schema object has a loss matrix.
 boolean is_labelled()
          Checks if this Schema has label information.
 boolean is_labelled(boolean fatalOnFalse)
          Checks if this Schema has label information.
 boolean is_nominal()
          Returns TRUE if all attributes in the schema are nominals } (or can be cast to nominals).
 AttrInfo label_info()
          Returns the label information.
 NominalAttrInfo nominal_attr_info(int attrNum)
          Casts the specified attribute to a nominal attribute.
 NominalAttrInfo nominal_label_info()
          Casts the label information to a nominal attribute.
 int num_attr_values(int attrNum)
          Returns the number of values possible for the specified attribute.
 int num_attr()
          Returns the number of attributes in this Schema object.
 int num_label_values()
          Returns the number of classification labels possible for this Schema.
 Schema project(boolean[] attrMask)
          Creates a new Schema object which contains only the specified attributes.
 Schema remove_attr(int attrNum)
          Returns a Schema with the given AttrInfo removed and the infos renumbered to be sequential starting at 0.
 void remove_loss_matrix()
          Removes a loss matrix from this Schema object.
 void set_loss_matrix(double[][] aLossMatrix)
          Sets the loss matrix to the matrix specified.
 int[] sort_labels()
          Create permutation array for labels if sorting is requested The array is owned by the caller and must be deleted.
static Schema.StringNum[] sort(Schema.StringNum[] sn)
          Sorts an array of StringNums from smallest to greatest value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Schema

public Schema(java.util.LinkedList attrInfos)
Constructor.
Parameters:
attrInfos - The information about each attribute to be stored in this Schema.

Schema

public Schema(java.util.LinkedList attrInfos,
              AttrInfo lInfo)
Constructor.
Parameters:
attrInfos - The information about the each attribute to be stored in this Schema.
lInfo - The information about the labels for each catagory.

Schema

public Schema(Schema source)
       throws java.lang.CloneNotSupportedException
Copy Constructor.
Parameters:
source - The Schema object to be copied.
Throws:
java.lang.CloneNotSupportedException - if the cloning process for the new Schema experiences an Exception.
Method Detail

has_loss_matrix

public boolean has_loss_matrix()
Checks if this Schema object has a loss matrix.
Returns:
TRUE if there is a loss matrix, FALSE otherwise.

get_loss_matrix

public double[][] get_loss_matrix()
Returns the loss matrix for this Schema object.
Returns:
The loss matrix.

set_loss_matrix

public void set_loss_matrix(double[][] aLossMatrix)
Sets the loss matrix to the matrix specified.
Parameters:
aLossMatrix - The new matrix to be stored in this Schema object.

establish_loss_matrix

public void establish_loss_matrix()
Allocates the loss matrix for this Schema object. The Schema must have label information or an error message will be displayed.

project

public Schema project(boolean[] attrMask)
               throws java.lang.CloneNotSupportedException
Creates a new Schema object which contains only the specified attributes.
Parameters:
attrMask - A boolean array where each element represents an attribute in the Schema. It should have have the same number of elements as attributes. Elements set to true will result in the corresponding attribute being included in the new Schema.
Returns:
The new Schema created.
Throws:
java.lang.CloneNotSupportedException - if the cloning process for the new Schema experiences an Exception.

nominal_attr_info

public NominalAttrInfo nominal_attr_info(int attrNum)
Casts the specified attribute to a nominal attribute.
Parameters:
attrNum - The index number of the specified attribute.
Returns:
The NominalAttrInfo object of the specified attribute.

num_attr_values

public int num_attr_values(int attrNum)
Returns the number of values possible for the specified attribute.
Parameters:
attrNum - The index number of the specified attribute.
Returns:
The number of values.

num_label_values

public int num_label_values()
Returns the number of classification labels possible for this Schema.
Returns:
The number of labels.

nominal_label_info

public NominalAttrInfo nominal_label_info()
Casts the label information to a nominal attribute.
Returns:
The NominalAttrInfo containing the label information.

label_info

public AttrInfo label_info()
Returns the label information.
Returns:
The AttrInfo containing the label information.

is_labelled

public boolean is_labelled()
Checks if this Schema has label information.
Returns:
TRUE if label information is present, FALSE otherwise.

is_labelled

public boolean is_labelled(boolean fatalOnFalse)
Checks if this Schema has label information.
Parameters:
fatalOnFalse - If set to TRUE, an error message will be displayed if there is no label information in this Schema.
Returns:
TRUE if label information is present, FALSE otherwise.

attr_name

public java.lang.String attr_name(int attrNum)
Returns the name of the specified attribute.
Parameters:
attrNum - The index number of the specified attribute.
Returns:
The name of the specified attribute.

num_attr

public int num_attr()
Returns the number of attributes in this Schema object.
Returns:
The number of attributes in this Schema object.

attr_info

public AttrInfo attr_info(int num)
Returns the AttrInfo object containing the specified attribute's information.
Parameters:
num - The index of the specified attribute.
Returns:
The AttrInfo object containing the specified attribute's information.

category_to_label_string

public java.lang.String category_to_label_string(int cat)
Returns the name of the specified category label.
Parameters:
cat - The specified category.
Returns:
The name of the specified category label.

display_names

public void display_names(java.io.Writer stream,
                          boolean protectChars,
                          java.lang.String header)
Displays the names file associated with the instances. The reason we don't call labelInfo.display_values() is to avoid printing the name of the label since a label doesn't have a name.
Parameters:
stream - The Writer to which the Schema will be displayed.
protectChars - TRUE if characters should be protected for display.
header - The String to use as a header to the display.

is_nominal

public boolean is_nominal()
Returns TRUE if all attributes in the schema are nominals } (or can be cast to nominals).
Returns:
TRUE if all of the attributes are nominal, FALSE otherwise.

sort_labels

public int[] sort_labels()
Create permutation array for labels if sorting is requested The array is owned by the caller and must be deleted.
Returns:
A array of index values of label inromation after sorting.

sort

public static Schema.StringNum[] sort(Schema.StringNum[] sn)
Sorts an array of StringNums from smallest to greatest value.
Parameters:
sn - An array of StringNum values to be sorted.
Returns:
The sorted array of StringNum values.

findindexofmin

public static int findindexofmin(Schema.StringNum[] sn,
                                 int start)
Finds the index of the minimum value in an array of StringNum values.
Parameters:
sn - The array of StringNum values to be searched.
start - The start index.
Returns:
The index of the smallest value after the start index.

remove_loss_matrix

public void remove_loss_matrix()
Removes a loss matrix from this Schema object. This occurs during reading if any extra values get added to the label

remove_attr

public Schema remove_attr(int attrNum)
Returns a Schema with the given AttrInfo removed and the infos renumbered to be sequential starting at 0.
Parameters:
attrNum - The number of the attribute to be removed.
Returns:
A copy of this Schema with the specified attribute removed.