public class Itemset
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected MyDataset |
dataset
The dataset which the itemset has access to.
|
protected static double |
MISSING_VALUE
Constant that represents the missing value.
|
protected double[] |
values
Values of the itemset.
|
protected double |
weight
The weight of the itemset.
|
Modifier | Constructor and Description |
---|---|
protected |
Itemset()
Default Constructor.
|
|
Itemset(double w,
double[] attributeValues)
Constructor that sets the values and the weight.
|
|
Itemset(int numAttributes)
Constructor of an instance that sets weight to one, all values to
be missing, and the reference to the dataset to null.
|
|
Itemset(Itemset itemset)
Constructor that copies the values and the weight.
|
Modifier and Type | Method and Description |
---|---|
MyAttribute |
attributeSparse(int indexOfIndex)
Returns the attribute with the given index.
|
int |
classIndex()
Returns the index of the class attribute.
|
boolean |
classIsMissing()
Function to test if the class attribute is missing.
|
java.lang.Object |
copy()
Function to copy an itemset.
|
void |
deleteAttributeAt(int position)
Deletes an attribute at the given position (0 to
numAttributes() - 1).
|
java.util.Enumeration |
enumerateAttributes()
Returns an enumeration of all the attributes.
|
boolean |
equalHeaders(Itemset inst)
Tests if the headers of two instances are equivalent.
|
MyAttribute |
getAttribute(int index)
Returns the attribute with the given index.
|
MyAttribute |
getClassAttribute()
Returns class attribute.
|
double |
getClassValue()
Returns the index of the value of the class.
|
MyDataset |
getDataset()
Returns the dataset of this itemset.
|
static double |
getMissingValue()
Returns the missing value.
|
java.lang.String |
getStringValue(int index)
Returns the value of the given attribute.
|
java.lang.String |
getStringValue(MyAttribute att)
Returns the value of the given attribute.
|
double |
getValue(int index)
Returns the value of the given attribute.
|
double |
getValue(MyAttribute att)
Returns the value of the given attribute.
|
double |
getValueSparse(int indexOfIndex)
Returns an instance's attribute value in internal format.
|
double |
getWeight()
Returns the itemset weight.
|
int |
index(int position)
Returns the index of the attribute stored at the given position.
|
void |
insertAttributeAt(int position)
Inserts an attribute at the given position (0 to
numAttributes()).
|
boolean |
isMissing(int index)
Function to check if a value is missing.
|
boolean |
isMissing(MyAttribute att)
Tests if a specific value is "missing".
|
boolean |
isMissingSparse(int indexOfIndex)
Tests if a specific value is "missing".
|
static boolean |
isMissingValue(double val)
Function to check if the value given is the missing value.
|
Itemset |
mergeInstance(Itemset inst)
Merges this instance with the given instance and returns
the result.
|
int |
numAttributes()
Returns the number of attributes.
|
int |
numClasses()
Returns the number of class values.
|
int |
numValues()
Returns the number of values.
|
void |
replaceMissingValues(double[] array)
Replaces all missing values in the instance with the
values contained in the given array.
|
void |
setClassMissing()
Function to set as missing the class value.
|
void |
setClassValue(double value)
Function to set a value.
|
void |
setClassValue(java.lang.String value)
Function to set a value.
|
void |
setDataset(MyDataset data)
Function to set the dataset.
|
void |
setMissing(int index)
Function to set a value as missing.
|
void |
setMissing(MyAttribute att)
Sets a specific value to be "missing".
|
void |
setValue(int index,
double value)
Function to set a value.
|
void |
setValue(int attIndex,
java.lang.String value)
Sets a value of a nominal or string attribute to the given
value.
|
void |
setValue(MyAttribute att,
double value)
Sets a specific value in the instance to the given value
(internal floating-point format).
|
void |
setValue(MyAttribute att,
java.lang.String value)
Sets a value of an nominal or string attribute to the given
value.
|
void |
setValueSparse(int indexOfIndex,
double value)
Sets a specific value in the instance to the given value
(internal floating-point format).
|
void |
setWeight(double w)
Function to set the weight.
|
java.lang.String |
toString()
Function to print the itemset.
|
java.lang.String |
toString(int attIndex)
Returns the description of one value of the instance as a
string.
|
java.lang.String |
toString(MyAttribute att)
Function to print of one value of the itemset.
|
protected MyDataset dataset
protected double[] values
protected double weight
protected static final double MISSING_VALUE
public Itemset(Itemset itemset)
itemset
- The itemset to copy.public Itemset(double w, double[] attributeValues)
w
- The weight.attributeValues
- The values.public Itemset(int numAttributes)
numAttributes
- the size of the instanceprotected Itemset()
public int index(int position)
position
- the positionpublic int classIndex()
public boolean classIsMissing()
public double getClassValue()
public MyAttribute getClassAttribute() throws java.lang.Exception
java.lang.Exception
- UnassignedDatasetException if the class is not set or the
instance doesn't have access to a datasetpublic int numClasses()
public MyAttribute getAttribute(int index)
index
- the attribute's indexpublic int numAttributes()
public int numValues()
public MyAttribute attributeSparse(int indexOfIndex) throws java.lang.Exception
indexOfIndex
- the index of the attribute's indexjava.lang.Exception
- UnassignedDatasetException if instance doesn't have access to a
datasetpublic void setClassValue(double value)
value
- The value.public void setClassValue(java.lang.String value) throws java.lang.Exception
value
- The value.java.lang.Exception
- If the index of the class is not set.public void setValue(int index, double value)
index
- The index of the attribute.value
- The value.public void setValueSparse(int indexOfIndex, double value)
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 final void setValue(int attIndex, java.lang.String value) throws java.lang.Exception
attIndex
- the attribute's indexvalue
- the new attribute value (If the attribute
is a string attribute and the value can't be found,
the value is added to the attribute).java.lang.Exception
- UnassignedDatasetException if the dataset is not set or IllegalArgumentException if the selected
attribute is not nominal or a string, or the supplied value couldn't
be found for a nominal attributepublic final void setValue(MyAttribute att, double value)
att
- the attributevalue
- 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 final void setValue(MyAttribute att, java.lang.String value) throws java.lang.Exception
att
- the attributevalue
- the new attribute value (If the attribute
is a string attribute and the value can't be found,
the value is added to the attribute).java.lang.Exception
- if the the attribute is not
nominal or a string, or the value couldn't be found for a nominal
attributepublic double getValueSparse(int indexOfIndex)
indexOfIndex
- the index of the attribute's indexpublic double getValue(int index)
index
- the attribute's indexpublic java.lang.String getStringValue(int index) throws java.lang.Exception
index
- the attribute's indexjava.lang.Exception
- if the Itemset doesn't have access to a dataset or
the attribute neither nominal nor string.public java.lang.String getStringValue(MyAttribute att) throws java.lang.Exception
att
- the attributejava.lang.Exception
- if the Itemset doesn't have access to a dataset or
the attribute neither nominal nor string.public double getValue(MyAttribute att)
att
- the attributepublic final void setWeight(double w)
w
- The weight.public final double getWeight()
public MyDataset getDataset()
public final void setDataset(MyDataset data)
data
- The dataset.public boolean isMissing(int index)
index
- The index of the attribute to check.public boolean isMissing(MyAttribute att)
att
- the attributepublic boolean isMissingSparse(int indexOfIndex)
indexOfIndex
- the index of the attribute's indexpublic static boolean isMissingValue(double val)
val
- The value to check.public static double getMissingValue()
public void setClassMissing()
public final void setMissing(int index)
index
- The index of the attribute.public final void setMissing(MyAttribute att)
att
- the attributepublic java.lang.Object copy()
public void insertAttributeAt(int position)
position
- the attribute's positionjava.lang.RuntimeException
- if the instance has accesss to a
datasetjava.lang.IllegalArgumentException
- if the position is out of rangepublic Itemset mergeInstance(Itemset inst)
inst
- the instance to be merged with this onepublic void deleteAttributeAt(int position)
position
- the attribute's positionjava.lang.RuntimeException
- if the instance has access to a
datasetpublic void replaceMissingValues(double[] array)
array
- containing the means and modesjava.lang.IllegalArgumentException
- if numbers of attributes are unequalpublic boolean equalHeaders(Itemset inst) throws java.lang.Exception
inst
- another instancejava.lang.Exception
- UnassignedDatasetException if instance doesn't have access to any
datasetpublic java.util.Enumeration enumerateAttributes() throws java.lang.Exception
java.lang.Exception
- UnassignedDatasetException if the instance doesn't
have access to a datasetpublic java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String toString(MyAttribute att) throws java.lang.Exception
att
- the attributejava.lang.Exception
public final java.lang.String toString(int attIndex) throws java.lang.Exception
attIndex
- the attribute's indexjava.lang.Exception