public class M5SparseInstance extends M5Instance
Modifier and Type | Field and Description |
---|---|
protected int[] |
m_Indices
The index of the attribute associated with each stored value.
|
protected int |
m_NumAttributes
The maximum number of values that can be stored.
|
m_AttValues, m_Dataset, m_Weight, MISSING_VALUE
Modifier | Constructor and Description |
---|---|
protected |
M5SparseInstance()
Default Constructor.
|
|
M5SparseInstance(double weight,
double[] attValues)
Constructor that generates a sparse instance from the given
parameters.
|
|
M5SparseInstance(double weight,
double[] attValues,
int[] indices,
int maxNumValues)
Constructor that inititalizes instance variable with given
values.
|
|
M5SparseInstance(int numAttributes)
Constructor of an instance that sets weight to one, all values to
be missing, and the reference to the dataset to null.
|
|
M5SparseInstance(M5Instance instance)
Constructor that generates a sparse instance from the given
instance.
|
|
M5SparseInstance(M5SparseInstance instance)
Constructor that copies the info from the given instance.
|
Modifier and Type | Method and Description |
---|---|
M5Attribute |
attributeSparse(int indexOfIndex)
Returns the attribute associated with the internal index.
|
java.lang.Object |
copy()
Produces a shallow copy of this instance.
|
int |
index(int position)
Returns the index of the attribute stored at the given position.
|
boolean |
isMissing(int attIndex)
Tests if a specific value is "missing".
|
int |
locateIndex(int index)
Locates the greatest index that is not greater than the
given index.
|
static void |
main(java.lang.String[] options)
Main method for testing this class.
|
M5Instance |
mergeInstance(M5Instance inst)
Merges this instance with the given instance and returns
the result.
|
int |
numAttributes()
Returns the number of attributes.
|
int |
numValues()
Returns the number of values in the sparse vector.
|
void |
replaceMissingValues(double[] array)
Replaces all missing values in the instance with the
values contained in the given array.
|
void |
setValue(int attIndex,
double value)
Sets a specific value in the instance to the given value
(internal floating-point format).
|
void |
setValueSparse(int indexOfIndex,
double value)
Sets a specific value in the instance to the given value
(internal floating-point format).
|
double[] |
toDoubleArray()
Returns the values of each attribute as an array of doubles.
|
java.lang.String |
toString()
Returns the description of one instance in sparse format.
|
double |
value(int attIndex)
Returns an instance's attribute value in internal format.
|
attribute, classAttribute, classIndex, classIsMissing, classValue, dataset, deleteAttributeAt, enumerateAttributes, equalHeaders, insertAttributeAt, isMissing, isMissingSparse, isMissingValue, missingValue, numClasses, setClassMissing, setClassValue, setClassValue, setDataset, setMissing, setMissing, setValue, setValue, setValue, setWeight, stringValue, stringValue, toString, toString, value, valueSparse, weight
protected int[] m_Indices
protected int m_NumAttributes
protected M5SparseInstance()
public M5SparseInstance(M5Instance instance)
instance
- the instance from which the attribute values
and the weight are to be copiedpublic M5SparseInstance(M5SparseInstance instance)
instance
- the instance from which the attribute
info is to be copiedpublic M5SparseInstance(double weight, double[] attValues)
weight
- the instance's weightattValues
- a vector of attribute valuespublic M5SparseInstance(double weight, double[] attValues, int[] indices, int maxNumValues)
weight
- the instance's weightattValues
- a vector of attribute values (just the ones to be stored)indices
- the indices of the given values in the full vectormaxNumValues
- the maximium number of values that can be storedpublic M5SparseInstance(int numAttributes)
numAttributes
- the size of the instancepublic M5Attribute attributeSparse(int indexOfIndex) throws java.lang.Exception
attributeSparse
in class M5Instance
indexOfIndex
- the index of the attribute's indexjava.lang.Exception
- if instance doesn't have access to a
datasetpublic java.lang.Object copy()
new M5SparseInstance(instance)
copy
in class M5Instance
public int index(int position)
index
in class M5Instance
position
- the positionpublic boolean isMissing(int attIndex)
isMissing
in class M5Instance
attIndex
- the attribute's indexpublic int locateIndex(int index)
index
- index given.public M5Instance mergeInstance(M5Instance inst)
mergeInstance
in class M5Instance
inst
- the instance to be merged with this onepublic int numAttributes()
numAttributes
in class M5Instance
public int numValues()
numValues
in class M5Instance
public void replaceMissingValues(double[] array)
replaceMissingValues
in class M5Instance
array
- containing the means and modesjava.lang.IllegalArgumentException
- if numbers of attributes are unequalpublic void setValue(int attIndex, double value)
setValue
in class M5Instance
attIndex
- the attribute's indexvalue
- the new attribute value (If the corresponding
attribute is nominal (or a string) then this is the new value's
index as a double).public void setValueSparse(int indexOfIndex, double value)
setValueSparse
in class M5Instance
indexOfIndex
- the index of the attribute's indexvalue
- the new attribute value (If the corresponding
attribute is nominal (or a string) then this is the new value's
index as a double).public double[] toDoubleArray()
toDoubleArray
in class M5Instance
public java.lang.String toString()
toString
in class M5Instance
public double value(int attIndex)
value
in class M5Instance
attIndex
- the attribute's indexpublic static void main(java.lang.String[] options)
options
- main args.