net.sf.myra.datamining.data
Class Metadata

java.lang.Object
  extended by net.sf.myra.datamining.data.Metadata
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Metadata
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class provides attribute metadata information.

Version:
$Revision: 2326 $ $Date:: 2011-01-25 10:54:47#$
Author:
Fernando Esteban Barril Otero
See Also:
Serialized Form

Field Summary
static java.lang.String MISSING_VALUE
          Constant value for missing attribute values.
 
Constructor Summary
Metadata()
          Default constructor.
 
Method Summary
 void add(Attribute attribute)
          Adds an attribute.
 Metadata clone()
           
 boolean contains(java.lang.String name)
          Returns true if this metadata instance contains an attribute with the specified name.
 boolean equals(Metadata o)
          Compares the specified metadata object with this object for equality.
 boolean equals(java.lang.Object o)
           
 Label expand(Label label)
          Expands the specified class label to include all ancestor class labels according to the class hierarchy.
 Attribute get(int index)
           
 Attribute get(java.lang.String attributeName)
          Returns the Attribute instance given its name.
 java.util.Collection<Attribute> getAttributes()
          Returns the collection attributes.
 ClassHierarchy getClassHierarchy()
           
 int getIndex(java.lang.String attribute)
          Returns the attribute index.
 Label getLabel()
          Returns the label prototype instance.
 java.lang.String getName()
          Returns the relation name.
 java.util.Collection<Attribute> getPredictor()
          Returns the collection of predictor attributes.
 NominalAttribute getTarget()
          Returns the class attribute.
 boolean isHierarchical()
          Tests if this metadata has a class hierarchy associated.
 boolean isMissing(int index, double value)
          Returns true if the specified value represents a missing value.
 boolean isTarget(Attribute attribute)
          Returns true if the specified attribute is the class attribute.
 void setClassHierarchy(ClassHierarchy hierarchy)
           
 void setName(java.lang.String name)
          Sets the relation name.
 void setTarget(int index)
          Sets the class attribute.
 void setTarget(NominalAttribute attribute)
          Sets the class attribute.
 net.sf.myra.framework.Graph<Term> toGraph()
          Returns the Graph representation of this metadata instance.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MISSING_VALUE

public static final java.lang.String MISSING_VALUE
Constant value for missing attribute values.

See Also:
Constant Field Values
Constructor Detail

Metadata

public Metadata()
Default constructor.

Method Detail

add

public void add(Attribute attribute)
Adds an attribute.

Parameters:
attribute - the attribute to add.

getName

public java.lang.String getName()
Returns the relation name.

Returns:
the relation name.

setName

public void setName(java.lang.String name)
Sets the relation name.

Parameters:
name - the name to set.

setTarget

public void setTarget(NominalAttribute attribute)
Sets the class attribute.

Parameters:
attribute - the class attribute.

setTarget

public void setTarget(int index)
Sets the class attribute.

Parameters:
index - the class attribute index.

getTarget

public NominalAttribute getTarget()
Returns the class attribute.

Returns:
the class attribute.

getLabel

public Label getLabel()
Returns the label prototype instance.

Returns:
the label prototype instance.

isTarget

public boolean isTarget(Attribute attribute)
Returns true if the specified attribute is the class attribute.

Parameters:
attribute - thee attribute to test.
Returns:
true if the specified attribute is the class attribute; false otherwise.

contains

public boolean contains(java.lang.String name)
Returns true if this metadata instance contains an attribute with the specified name.

Parameters:
name - the attribute's name.
Returns:
true if there is an attribute with the specified name; false otherwise.

get

public Attribute get(java.lang.String attributeName)
Returns the Attribute instance given its name.

Parameters:
attributeName - the attribute name.
Returns:
the Attribute instance given its name.

get

public Attribute get(int index)

getIndex

public int getIndex(java.lang.String attribute)
Returns the attribute index.

Parameters:
attribute - the attribute name.
Returns:
the attribute index.

getAttributes

public java.util.Collection<Attribute> getAttributes()
Returns the collection attributes.

Returns:
the collection attributes.

getPredictor

public java.util.Collection<Attribute> getPredictor()
Returns the collection of predictor attributes.

Returns:
the collection of predictor attributes.

getClassHierarchy

public ClassHierarchy getClassHierarchy()
Returns:
the hierarchy

setClassHierarchy

public void setClassHierarchy(ClassHierarchy hierarchy)
Parameters:
hierarchy - the hierarchy to set

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

equals

public boolean equals(Metadata o)
Compares the specified metadata object with this object for equality. Returns true if the two instances have the same attribute list and if the given instance have the class attribute value.

Parameters:
o - the metadata object to be compared for equality with this object.
Returns:
true if the specified metadata object is equal to this object; false otherwise.

toGraph

public net.sf.myra.framework.Graph<Term> toGraph()
Returns the Graph representation of this metadata instance. The original Ant-Miner version only supports nominal attributes, so an UnsupportedOperationException is thrown if a ContinuousAttribute instance is found. For every nominal attribute value, a node is added to the graph in the form attribute = valuei. Note that the class attribute is not included in the graph.

Returns:
the Graph representation of this metadata instance.
See Also:
Metadata, Graph

clone

public Metadata clone()
Overrides:
clone in class java.lang.Object

expand

public Label expand(Label label)
Expands the specified class label to include all ancestor class labels according to the class hierarchy.

Parameters:
label - the class label to be expanded.
Returns:
the expanded class label instance.

isHierarchical

public boolean isHierarchical()
Tests if this metadata has a class hierarchy associated.

Returns:
true if there is a class hierarchy associated; false otherwise.

isMissing

public boolean isMissing(int index,
                         double value)
Returns true if the specified value represents a missing value.

Parameters:
index - the attribute index.
value - the value to check.
Returns:
true if the specified value represents a missing value; otherwise false.


Copyright © 2013. All Rights Reserved.