All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.core.BinarySparseInstance

java.lang.Object
    |
    +----weka.core.Instance
            |
            +----weka.core.SparseInstance
                    |
                    +----weka.core.BinarySparseInstance

public class BinarySparseInstance
extends SparseInstance
Class for storing a binary-data-only instance as a sparse vector. A sparse instance only requires storage for those attribute values that are non-zero. Since the objective is to reduce storage requirements for datasets with large numbers of default values, this also includes nominal attributes -- the first nominal value (i.e. that which has index 0) will not require explicit storage, so rearrange your nominal attribute value orderings if necessary. Missing values are not supported, and will be treated as 1 (true).


Constructor Index

 o BinarySparseInstance(double, double[])
Constructor that generates a sparse instance from the given parameters.
 o BinarySparseInstance(double, int[], int)
Constructor that inititalizes instance variable with given values.
 o BinarySparseInstance(Instance)
Constructor that generates a sparse instance from the given instance.
 o BinarySparseInstance(int)
Constructor of an instance that sets weight to one, all values to 1, and the reference to the dataset to null.
 o BinarySparseInstance(SparseInstance)
Constructor that copies the info from the given instance.

Method Index

 o copy()
Produces a shallow copy of this instance.
 o main(String[])
Main method for testing this class.
 o mergeInstance(Instance)
Merges this instance with the given instance and returns the result.
 o replaceMissingValues(double[])
Does nothing, since we don't support missing values.
 o setValue(int, double)
Sets a specific value in the instance to the given value (internal floating-point format).
 o setValueSparse(int, double)
Sets a specific value in the instance to the given value (internal floating-point format).
 o toDoubleArray()
Returns the values of each attribute as an array of doubles.
 o toString()
Returns the description of one instance in sparse format.
 o value(int)
Returns an instance's attribute value in internal format.
 o valueSparse(int)
Returns an instance's attribute value in internal format.

Constructor Detail

 o BinarySparseInstance
public BinarySparseInstance(Instance instance)
          Constructor that generates a sparse instance from the given instance. Reference to the dataset is set to null. (ie. the instance doesn't have access to information about the attribute types)
Parameters:
instance - the instance from which the attribute values and the weight are to be copied
 o BinarySparseInstance
public BinarySparseInstance(SparseInstance instance)
          Constructor that copies the info from the given instance. Reference to the dataset is set to null. (ie. the instance doesn't have access to information about the attribute types)
Parameters:
instance - the instance from which the attribute info is to be copied
 o BinarySparseInstance
public BinarySparseInstance(double weight,
                            double attValues[])
          Constructor that generates a sparse instance from the given parameters. Reference to the dataset is set to null. (ie. the instance doesn't have access to information about the attribute types)
Parameters:
weight - the instance's weight
attValues - a vector of attribute values
 o BinarySparseInstance
public BinarySparseInstance(double weight,
                            int indices[],
                            int maxNumValues)
          Constructor that inititalizes instance variable with given values. Reference to the dataset is set to null. (ie. the instance doesn't have access to information about the attribute types)
Parameters:
weight - the instance's weight
indices - the indices of the given values in the full vector
maxNumValues - the maximium number of values that can be stored
 o BinarySparseInstance
public BinarySparseInstance(int numAttributes)
          Constructor of an instance that sets weight to one, all values to 1, and the reference to the dataset to null. (ie. the instance doesn't have access to information about the attribute types)
Parameters:
numAttributes - the size of the instance

Method Detail

 o copy
public java.lang.Object copy()
          Produces a shallow copy of this instance. The copy doesn't have access to a dataset.
Returns:
the shallow copy
Overrides:
copy in class SparseInstance
 o mergeInstance
public Instance mergeInstance(Instance inst)
          Merges this instance with the given instance and returns the result. Dataset is set to null.
Parameters:
inst - the instance to be merged with this one
Returns:
the merged instances
Overrides:
mergeInstance in class SparseInstance
 o replaceMissingValues
public void replaceMissingValues(double array[])
          Does nothing, since we don't support missing values.
Parameters:
array - containing the means and modes
Throws:
java.lang.IllegalArgumentException - if numbers of attributes are unequal
Overrides:
replaceMissingValues in class SparseInstance
 o setValue
public void setValue(int attIndex,
                     double value)
          Sets a specific value in the instance to the given value (internal floating-point format). Performs a deep copy of the vector of attribute values before the value is set.
Parameters:
attIndex - the attribute's index
value - the new attribute value (If the corresponding attribute is nominal (or a string) then this is the new value's index as a double).
Overrides:
setValue in class SparseInstance
 o setValueSparse
public void setValueSparse(int indexOfIndex,
                           double value)
          Sets a specific value in the instance to the given value (internal floating-point format). Performs a deep copy of the vector of attribute values before the value is set.
Parameters:
indexOfIndex - the index of the attribute's index
value - the new attribute value (If the corresponding attribute is nominal (or a string) then this is the new value's index as a double).
Overrides:
setValueSparse in class SparseInstance
 o toDoubleArray
public double[] toDoubleArray()
          Returns the values of each attribute as an array of doubles.
Returns:
an array containing all the instance attribute values
Overrides:
toDoubleArray in class SparseInstance
 o toString
public java.lang.String toString()
          Returns the description of one instance in sparse format. If the instance doesn't have access to a dataset, it returns the internal floating-point values. Quotes string values that contain whitespace characters.
Returns:
the instance's description as a string
Overrides:
toString in class SparseInstance
 o value
public double value(int attIndex)
          Returns an instance's attribute value in internal format.
Parameters:
attIndex - the attribute's index
Returns:
the specified value as a double (If the corresponding attribute is nominal (or a string) then it returns the value's index as a double).
Overrides:
value in class SparseInstance
 o valueSparse
public final double valueSparse(int indexOfIndex)
          Returns an instance's attribute value in internal format. Does exactly the same thing as value() if applied to an Instance.
Parameters:
indexOfIndex - the index of the attribute's index
Returns:
the specified value as a double (If the corresponding attribute is nominal (or a string) then it returns the value's index as a double).
Overrides:
valueSparse in class Instance
 o main
public static void main(java.lang.String options[])
          Main method for testing this class.

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home