|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object mulan.data.MultiLabelInstances
public class MultiLabelInstances
Implements multi-label instances data set. Multi-label data are stored in Weka's
Instances
. The class is a convenient wrapper. The data are loaded form
data file, checked for valid format. If hierarchy for labels is specified via
XML meta-data file, the data file is cross-checked with XML for consistency.
Applied rules:
- label names must be unique
- all labels in XML meta-data must be defined also in ARFF data set
- each label attribute must be nominal with binary values
- if labels has hierarchy, then if child labels indicates true
of some
data instance, then all its parent labels must indicate also true
for that instance
Constructor Summary | |
---|---|
MultiLabelInstances(InputStream arffDataStream,
InputStream xmlLabelsDefStream)
Creates a new instance of MultiLabelInstances data from the supplied InputStream
data source. |
|
MultiLabelInstances(InputStream arffDataStream,
int numLabelAttributes)
Creates a new instance of MultiLabelInstances data from the supplied InputStream
data source. |
|
MultiLabelInstances(Instances dataSet,
LabelsMetaData labelsMetaData)
Creates a new instance of MultiLabelInstances data from existing Instances
and LabelsMetaData . |
|
MultiLabelInstances(Instances data,
String xmlLabelsDefFilePath)
Creates a new instance of MultiLabelInstances data. |
|
MultiLabelInstances(String arffFilePath,
int numLabelAttributes)
Creates a new instance of MultiLabelInstances data. |
|
MultiLabelInstances(String arffFilePath,
String xmlLabelsDefFilePath)
Creates a new instance of MultiLabelInstances data. |
Method Summary | |
---|---|
MultiLabelInstances |
clone()
Returns a deep copy of the MultiLabelInstances instance. |
double |
getCardinality()
Gets the cardinality of the dataset |
Instances |
getDataSet()
Gets underlying Instances , which contains all data. |
int |
getDepth(String labelName)
Calculates the depth of a label, in the Hierarchy of the tree of labels. |
Set<Attribute> |
getFeatureAttributes()
Gets the Set of feature Attribute instances of
this MultiLabelInstances instance. |
int[] |
getFeatureIndices()
Gets the array with indices of feature attributes stored in underlying Instances data set. |
Set<Attribute> |
getLabelAttributes()
Gets the Set of label Attribute instances of
this MultiLabelInstances instance. |
HashMap<String,Integer> |
getLabelDepth()
Create a HashMap that contains every label, with its depth in the Hierarchical tree |
int[] |
getLabelDepthIndices()
Returns the depth of the labels |
int[] |
getLabelIndices()
|
LabelsMetaData |
getLabelsMetaData()
Gets the LabelsMetaData instance, which contains descriptive meta-data about
label attributes stored in underlying Instances data set. |
Map<String,Integer> |
getLabelsOrder()
|
int |
getNumInstances()
Gets the number of instances |
int |
getNumLabels()
Gets the number of labels (label attributes) |
boolean |
hasMissingLabels(Instance instance)
Method that checks whether an instance has missing labels |
MultiLabelInstances |
reintegrateModifiedDataSet(Instances modifiedDataSet)
If Instances data set are retrieved from MultiLabelInstances and
post-processed, modified by custom code, it can be again reintegrated into
MultiLabelInstances if needed. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultiLabelInstances(String arffFilePath, int numLabelAttributes) throws InvalidDataFormatException
MultiLabelInstances
data.
The label attributes are assumed to be at the end of ARFF data file. The count
is specified by parameter. Based on these attributes the LabelsMetaData
are created.
arffFilePath
- the path to ARFF file containing the datanumLabelAttributes
- the number of ARFF data set attributes which are labels.
ArgumentNullException
- if arrfFilePath is null
IllegalArgumentException
- if numLabelAttribures is less than 2
InvalidDataFormatException
- if format of loaded multi-label data is invalid
DataLoadException
- if ARFF data file can not be loadedpublic MultiLabelInstances(InputStream arffDataStream, int numLabelAttributes) throws InvalidDataFormatException
MultiLabelInstances
data from the supplied InputStream
data source. The data in the stream are assumed to be in ARFF format.
The label attributes in ARFF data are assumed to be the last ones. Based on those attributes
the LabelsMetaData
are created.
arffDataStream
- the InputStream
data source to load data in ARFF formatnumLabelAttributes
- the number of last ARFF data set attributes which are labels.
ArgumentNullException
- if InputStream
data source is null
IllegalArgumentException
- if number of labels attributes is less than 2
InvalidDataFormatException
- if format of loaded multi-label data is invalid
DataLoadException
- if ARFF data can not be loadedpublic MultiLabelInstances(Instances data, String xmlLabelsDefFilePath) throws InvalidDataFormatException
MultiLabelInstances
data.
The Instances object and labels meta-data are loaded separately. The load failure is
indicated by DataLoadException
. When data are loaded, validations are applied
to ensure consistency between ARFF data and specified labels meta-data.
data
- the Instances object containing the dataxmlLabelsDefFilePath
- the path to XML file containing labels meta-data
IllegalArgumentException
- if input parameters refers to non-existing files
InvalidDataFormatException
- if format of loaded multi-label data is invalid
DataLoadException
- if XML meta-data of ARFF data file can not be loadedpublic MultiLabelInstances(String arffFilePath, String xmlLabelsDefFilePath) throws InvalidDataFormatException
MultiLabelInstances
data.
The ARFF data file and labels meta-data are loaded separately. The load failure is
indicated by DataLoadException
. When data are loaded, validations are applied
to ensure consistency between ARFF data and specified labels meta-data.
arffFilePath
- the path to ARFF file containing the dataxmlLabelsDefFilePath
- the path to XML file containing labels meta-data
ArgumentNullException
- if input parameters are null
IllegalArgumentException
- if input parameters refers to non-existing files
InvalidDataFormatException
- if format of loaded multi-label data is invalid
DataLoadException
- if XML meta-data of ARFF data file can not be loadedpublic MultiLabelInstances(InputStream arffDataStream, InputStream xmlLabelsDefStream) throws InvalidDataFormatException
MultiLabelInstances
data from the supplied InputStream
data source. The data in the stream are assumed to be in ARFF format.
The labels meta data for ARFF data are retrieved separately from the different InputStream
data source. The meta data are assumed to be in XML format and conform to valid schema.
Data load load failure is indicated by DataLoadException
. When data are loaded, validations
are applied to ensure consistency between ARFF data and specified labels meta-data.
arffDataStream
- the InputStream
data source to load data in ARFF formatxmlLabelsDefStream
- the InputStream
data source to load XML labels meta data
ArgumentNullException
- if input parameters are null
IllegalArgumentException
- if input parameters refers to non-existing files
InvalidDataFormatException
- if format of loaded multi-label data is invalid
DataLoadException
- if XML meta-data of ARFF data can not be loadedpublic MultiLabelInstances(Instances dataSet, LabelsMetaData labelsMetaData) throws InvalidDataFormatException
MultiLabelInstances
data from existing Instances
and LabelsMetaData
. The input parameters are not copied. Internally are stored only
references.InvalidDataFormatException
.
dataSet
- the data set with data instances in multi-label formatlabelsMetaData
- the meta-data about label attributes of data set
IllegalArgumentException
- if input parameters are null
InvalidDataFormatException
- if multi-label data format is not validMethod Detail |
---|
public int getNumLabels()
public int getNumInstances()
public double getCardinality()
public int[] getLabelIndices()
public Map<String,Integer> getLabelsOrder()
public Set<Attribute> getLabelAttributes()
Set
of label Attribute
instances of
this MultiLabelInstances
instance.
public int[] getFeatureIndices()
Instances
data set.
public Set<Attribute> getFeatureAttributes()
Set
of feature Attribute
instances of
this MultiLabelInstances
instance.
Set
of feature Attribute
instancespublic LabelsMetaData getLabelsMetaData()
LabelsMetaData
instance, which contains descriptive meta-data about
label attributes stored in underlying Instances
data set.
public Instances getDataSet()
Instances
, which contains all data.
public MultiLabelInstances reintegrateModifiedDataSet(Instances modifiedDataSet) throws InvalidDataFormatException
Instances
data set are retrieved from MultiLabelInstances
and
post-processed, modified by custom code, it can be again reintegrated into
MultiLabelInstances
if needed. The underlying LabelsMetaData
are
modified to reflect changes in data set. The method creates new instance of
MultiLabelInstances
with modified data set and new meta-data.
Attribute
to the existing Instances
Instance
from the existing Instances
Attribute
to the existing Instances
modifiedDataSet
- the modified data set
IllegalArgumentException
- if specified modified data set is null
InvalidDataFormatException
- if multi-label data format with specified modifications is not validpublic MultiLabelInstances clone()
MultiLabelInstances
instance.
clone
in class Object
public HashMap<String,Integer> getLabelDepth()
public int getDepth(String labelName)
labelName
-
public int[] getLabelDepthIndices()
public boolean hasMissingLabels(Instance instance)
instance
- one instance of this dataset
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |