Package com.yahoo.labs.samoa.instances
Class SparseInstanceData
- java.lang.Object
-
- com.yahoo.labs.samoa.instances.SparseInstanceData
-
- All Implemented Interfaces:
InstanceData
,Serializable
- Direct Known Subclasses:
FilteredSparseInstanceData
public class SparseInstanceData extends Object implements InstanceData
The Class SparseInstanceData.- Author:
- abifet
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double[]
attributeValues
The attribute values.protected int[]
indexValues
The index values.protected int
numberAttributes
The number of attributes.
-
Constructor Summary
Constructors Constructor Description SparseInstanceData(double[] attributeValues, int[] indexValues, int numberAttributes)
Instantiates a new sparse instance data.SparseInstanceData(int length)
Instantiates a new sparse instance data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstanceData
copy()
Produces a shallow copy of this instance data.void
deleteAttributeAt(int position)
Deletes an attribute at the given position (0 to numAttributes() - 1).double[]
getAttributeValues()
Gets the attribute values.int[]
getIndexValues()
Gets the index values.int
getNumberAttributes()
Gets the number attributes.int
index(int indexAttribute)
Index.void
insertAttributeAt(int position)
Inserts an attribute.boolean
isMissing(int indexAttribute)
Checks if is missing.boolean
isMissingSparse(int indexAttribute)
Checks if is missing sparse.int
locateIndex(int index)
Locates the greatest index that is not greater than the given index.int
numAttributes()
Gets the number of attributes.int
numValues()
Num values.void
setAttributeValues(double[] attributeValues)
Sets the attribute values.void
setIndexValues(int[] indexValues)
Sets the index values.void
setNumberAttributes(int numberAttributes)
Sets the number of attributes.void
setValue(int attributeIndex, double d)
Sets the value.double[]
toDoubleArray()
To double array.double
value(int indexAttribute)
Value.double
valueSparse(int indexAttribute)
Value sparse.
-
-
-
Constructor Detail
-
SparseInstanceData
public SparseInstanceData(double[] attributeValues, int[] indexValues, int numberAttributes)
Instantiates a new sparse instance data.- Parameters:
attributeValues
- the attribute valuesindexValues
- the index valuesnumberAttributes
- the number attributes
-
SparseInstanceData
public SparseInstanceData(int length)
Instantiates a new sparse instance data.- Parameters:
length
- the length
-
-
Method Detail
-
getAttributeValues
public double[] getAttributeValues()
Gets the attribute values.- Returns:
- the attribute values
-
setAttributeValues
public void setAttributeValues(double[] attributeValues)
Sets the attribute values.- Parameters:
attributeValues
- the new attribute values
-
getIndexValues
public int[] getIndexValues()
Gets the index values.- Returns:
- the index values
-
setIndexValues
public void setIndexValues(int[] indexValues)
Sets the index values.- Parameters:
indexValues
- the new index values
-
getNumberAttributes
public int getNumberAttributes()
Gets the number attributes.- Returns:
- the number attributes
-
setNumberAttributes
public void setNumberAttributes(int numberAttributes)
Sets the number of attributes.- Parameters:
numberAttributes
- the new number attributes
-
numAttributes
public int numAttributes()
Gets the number of attributes.- Specified by:
numAttributes
in interfaceInstanceData
- Returns:
- the int
-
value
public double value(int indexAttribute)
Value.- Specified by:
value
in interfaceInstanceData
- Parameters:
indexAttribute
- the index attribute- Returns:
- the double
-
isMissing
public boolean isMissing(int indexAttribute)
Checks if is missing.- Specified by:
isMissing
in interfaceInstanceData
- Parameters:
indexAttribute
- the index attribute- Returns:
- true, if is missing
-
numValues
public int numValues()
Num values.- Specified by:
numValues
in interfaceInstanceData
- Returns:
- the int
-
index
public int index(int indexAttribute)
Index.- Specified by:
index
in interfaceInstanceData
- Parameters:
indexAttribute
- the index attribute- Returns:
- the int
-
valueSparse
public double valueSparse(int indexAttribute)
Value sparse.- Specified by:
valueSparse
in interfaceInstanceData
- Parameters:
indexAttribute
- the index attribute- Returns:
- the double
-
isMissingSparse
public boolean isMissingSparse(int indexAttribute)
Checks if is missing sparse.- Specified by:
isMissingSparse
in interfaceInstanceData
- Parameters:
indexAttribute
- the index attribute- Returns:
- true, if is missing sparse
-
toDoubleArray
public double[] toDoubleArray()
To double array.- Specified by:
toDoubleArray
in interfaceInstanceData
- Returns:
- the double[]
-
setValue
public void setValue(int attributeIndex, double d)
Sets the value.- Specified by:
setValue
in interfaceInstanceData
- Parameters:
attributeIndex
- the attribute indexd
- the d
-
locateIndex
public int locateIndex(int index)
Locates the greatest index that is not greater than the given index.- Returns:
- the internal index of the attribute index. Returns -1 if no index with this property could be found
-
deleteAttributeAt
public void deleteAttributeAt(int position)
Deletes an attribute at the given position (0 to numAttributes() - 1).- Specified by:
deleteAttributeAt
in interfaceInstanceData
- Parameters:
position
- the attribute's position
-
insertAttributeAt
public void insertAttributeAt(int position)
Description copied from interface:InstanceData
Inserts an attribute.- Specified by:
insertAttributeAt
in interfaceInstanceData
- Parameters:
position
- the indes
-
copy
public InstanceData copy()
Description copied from interface:InstanceData
Produces a shallow copy of this instance data.- Specified by:
copy
in interfaceInstanceData
- Returns:
- the shallow copy
-
-