shared
Class RealAndLabelColumn

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

public class RealAndLabelColumn
extends java.lang.Object

The RealAttributeColumn class provides a array representation for a real column (real attribute, label and weight). The array representation has better data locality than a doubly linked instance list and thus is more efficient for discretization. RealAttributeColumn includes the AttrInfo for the real attribute and the label. However, these are const references, therefore whoever owns these AttrInfos must not delete them until the RealAttribueColumn referring to them has been deleted.

The size of the data array must not exceed that given in the constructor. Because the class is used for transforming already existing instance lists (see InstanceList.transpose), the maximum size can be estimated well enough in advance.

Zero-weight instances added to the column are disregarded. Since an instance with zero weight is equivalent to no instances, such instances should be disregarded by tasks that use the RealAndLabelColumn (like discretization and the like).


Constructor Summary
RealAndLabelColumn(int length, int labelCount, RealAttrInfo rai, NominalAttrInfo nai)
          RealAndLabelColumn constructor for labelled columns.
RealAndLabelColumn(int length, RealAttrInfo rai)
          RealAndLabelColumn constructor for unlabelled columns
 
Method Summary
 void add_known(float value, double weight)
          Adds a known real value and weight.
 void add_known(float value, int label, double weight)
          Adds a known real value, label and weight.
 void add_unknown(double weight)
          Adds a "unknown" value and weight.
 void add_unknown(int label, double weight)
          Adds a "unknown" value, label and weight.
 RealAttrInfo attr_info()
          Returns the information on the real attribute stored in this column.
 AttrLabelPair index(int index)
          Returns the real/label pair at the specified index number.
 int init_dist_counts(double[][] splitAndLabelDist, double[] labelDist)
          Fills the fields of the splitAndLabelDist array, returns the number of used labels for known instances.
 int known_count()
          Returns the count of known real values.
 double known_weight()
          Returns the weight of the known values.
 int label_count()
          Return the number of possible labels.
 void sort()
          Sorts the real/label pairs.
 double total_weight()
          Returns the total weight of all values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RealAndLabelColumn

public RealAndLabelColumn(int length,
                          int labelCount,
                          RealAttrInfo rai,
                          NominalAttrInfo nai)
RealAndLabelColumn constructor for labelled columns.
Parameters:
length - The number of real/label pairs to be stored.
labelCount - Number of possible labels.
rai - Attribute information for the real attribute stored.
nai - Attribute information for the label attribute.

RealAndLabelColumn

public RealAndLabelColumn(int length,
                          RealAttrInfo rai)
RealAndLabelColumn constructor for unlabelled columns
Parameters:
length - The number of real values to be stored.
rai - Attribute information for the real attribute stored.
Method Detail

attr_info

public RealAttrInfo attr_info()
Returns the information on the real attribute stored in this column.
Returns:
The information on the real attribute stored in this column.

add_unknown

public void add_unknown(int label,
                        double weight)
Adds a "unknown" value, label and weight.
Parameters:
label - The label value associated with the unknown value.
weight - The weight of this real/label pair.

add_unknown

public void add_unknown(double weight)
Adds a "unknown" value and weight.
Parameters:
weight - The weight of this real value.

add_known

public void add_known(float value,
                      int label,
                      double weight)
Adds a known real value, label and weight.
Parameters:
value - Real value to be stored.
label - Label associated with this real value.
weight - The weight of this real/label pair.

add_known

public void add_known(float value,
                      double weight)
Adds a known real value and weight.
Parameters:
value - Real value to be stored.
weight - The weight of this real value.

known_weight

public double known_weight()
Returns the weight of the known values.
Returns:
The weight of the known values.

index

public AttrLabelPair index(int index)
Returns the real/label pair at the specified index number.
Parameters:
index - The index to be returned.
Returns:
The real/label pair.

known_count

public int known_count()
Returns the count of known real values.
Returns:
The count of known real values.

total_weight

public double total_weight()
Returns the total weight of all values.
Returns:
The total weight of all values.

init_dist_counts

public int init_dist_counts(double[][] splitAndLabelDist,
                            double[] labelDist)
Fills the fields of the splitAndLabelDist array, returns the number of used labels for known instances. For the meaning of splitAndLabelDist and labelDist see entropy.java.
Parameters:
splitAndLabelDist - The split and label distribution to be filled.
labelDist - The label to be filled.
Returns:
The number of labels used.

label_count

public int label_count()
Return the number of possible labels.
Returns:
The number of possible labels.

sort

public void sort()
Sorts the real/label pairs.