Class ProblemDescription

java.lang.Object
  extended by ProblemDescription
All Implemented Interfaces:
java.io.Serializable
public class ProblemDescription
extends java.lang.Object
implements java.io.Serializable

Class for describing learning problems (.names files).

Version:
1.0
Author:
Fabien Torre
See Also:
Serialized Form

Constructor Summary
ProblemDescription(java.lang.String problemPath, java.lang.Boolean verbose)
          Construction from a .names file.
 
Method Summary
 int getAttributeId(java.lang.String attributeName)
          Returns the identifier of an attribute.
 java.lang.String getAttributeName(int attributeId)
          Returns the name of an attribute given its identifier.
 AttributeType getAttributeType(int attributeId)
          Returns the type of an attribute.
 int getClassId(java.lang.String className)
          Returns the identifier of a class.
 java.lang.String getClassName(int classId)
          Returns the name of the class from its identifier.
 java.util.Iterator getContinuousAttributesIterator()
          Returns an iterator on continuous attributes.
 java.util.Iterator getDiscreteAttributesIterator()
          Returns an iterator on discrete attributes.
 int getDiscreteValueId(int attributeId, java.lang.String value)
          Returns the identifier of a value.
 java.lang.String getDiscreteValueName(int attributeId, int valueId)
          Returns the name of a value.
 int getNumberOfAttributes()
          Returns the number of attributes used to describe examples.
 int getNumberOfClasses()
          Returns the number of classes in the classification problem.
 int getNumberOfValues(int attributeId)
          Returns the number of possible values for a discrete attribute.
 java.util.Collection getPossibleDiscreteValues(int attributeId)
          Returns the possible values of a given discrete attribute.
 java.lang.String getProblemLocation()
          Returns path to the problem files.
 AttributeType getRandomAttributeType()
           
 int getRandomContinuousAttribute()
           
 int getRandomDiscreteAttribute()
           
 int getRandomDiscreteValue(int attributeId)
           
 java.util.Iterator getUsefulAttributesIterator()
          Returns an iterator on useful attributes (neither labels nor ignored attributes).
 java.lang.Boolean isContinuousAttribute(int attributeId)
          Test if a given attribute is continuous, or not.
 java.lang.Boolean isDiscreteAttribute(int attributeId)
          Test if a given attribute is discrete, or not.
 java.lang.Boolean isIgnoredAttribute(int attributeId)
          Test if a given attribute should be ignored, or not.
 java.lang.Boolean isKnownClass(java.lang.String className)
          Test if a class is authorized or not.
 java.lang.Boolean isLabelAttribute(int attributeId)
          Test if a given attribute is a label, or not.
 java.lang.Boolean isPossibleValue(int attributeId, java.lang.String value)
          Test if a value is authorized for a given attributeId, or not.
 java.lang.String toString()
          Transforms a ProblemDescription into String.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProblemDescription

public ProblemDescription(java.lang.String problemPath,
                          java.lang.Boolean verbose)
Construction from a .names file.

Parameters:
problemPath - path to the problem's file.
verbose - true to get comments, false for silence.
Method Detail

getProblemLocation

public java.lang.String getProblemLocation()
Returns path to the problem files.

Returns:
path to the problem files.

getNumberOfClasses

public int getNumberOfClasses()
Returns the number of classes in the classification problem.

Returns:
the number of classes.

getClassId

public int getClassId(java.lang.String className)
Returns the identifier of a class.

Parameters:
className - name of the class.

getClassName

public java.lang.String getClassName(int classId)
Returns the name of the class from its identifier.

Parameters:
classId - identifier of the class.

isKnownClass

public java.lang.Boolean isKnownClass(java.lang.String className)
Test if a class is authorized or not.

Parameters:
className - name of the class.
Returns:
true if the class is authorized, else false.

getNumberOfAttributes

public int getNumberOfAttributes()
Returns the number of attributes used to describe examples.

Returns:
the number of attributes.

getAttributeId

public int getAttributeId(java.lang.String attributeName)
Returns the identifier of an attribute.

Parameters:
attributeName - name of the attribute.

getAttributeName

public java.lang.String getAttributeName(int attributeId)
Returns the name of an attribute given its identifier.

Parameters:
attributeId - identifier of the attribute.

getAttributeType

public AttributeType getAttributeType(int attributeId)
Returns the type of an attribute.

Parameters:
attributeId - number id of the attribute.
Returns:
the type of the attribute.

isLabelAttribute

public java.lang.Boolean isLabelAttribute(int attributeId)
Test if a given attribute is a label, or not.

Parameters:
attributeId - number id of the attribute.
Returns:
true if the attribute is a label.

isIgnoredAttribute

public java.lang.Boolean isIgnoredAttribute(int attributeId)
Test if a given attribute should be ignored, or not.

Parameters:
attributeId - number id of the attribute.
Returns:
true if the attribute should be ignored.

isContinuousAttribute

public java.lang.Boolean isContinuousAttribute(int attributeId)
Test if a given attribute is continuous, or not.

Parameters:
attributeId - number id of the attribute.
Returns:
true if the attribute is continuous.

isDiscreteAttribute

public java.lang.Boolean isDiscreteAttribute(int attributeId)
Test if a given attribute is discrete, or not.

Parameters:
attributeId - number id of the attribute.
Returns:
true if the attribute is discrete.

getNumberOfValues

public int getNumberOfValues(int attributeId)
Returns the number of possible values for a discrete attribute.

Parameters:
attributeId - number id of the attribute.
Returns:
the number of possible values for the given attribute.

isPossibleValue

public java.lang.Boolean isPossibleValue(int attributeId,
                                         java.lang.String value)
Test if a value is authorized for a given attributeId, or not.

Parameters:
attributeId - number id of the attribute.
value - to check.
Returns:
true if the given value is possible for the given attribute.

getDiscreteValueId

public int getDiscreteValueId(int attributeId,
                              java.lang.String value)
Returns the identifier of a value.

Parameters:
attributeId - number id of the attribute.
value - to find.
Returns:
the identifier of the given value.

getDiscreteValueName

public java.lang.String getDiscreteValueName(int attributeId,
                                             int valueId)
Returns the name of a value.

Parameters:
attributeId - number id of the attribute.
valueId - number id of the value.
Returns:
the name of the given value.

getUsefulAttributesIterator

public java.util.Iterator getUsefulAttributesIterator()
Returns an iterator on useful attributes (neither labels nor ignored attributes).

Returns:
an iterator on useful attributes (neither labels nor ignored attributes).

getDiscreteAttributesIterator

public java.util.Iterator getDiscreteAttributesIterator()
Returns an iterator on discrete attributes.

Returns:
an iterator on discrete attributes.

getRandomAttributeType

public AttributeType getRandomAttributeType()

getRandomContinuousAttribute

public int getRandomContinuousAttribute()

getRandomDiscreteAttribute

public int getRandomDiscreteAttribute()

getRandomDiscreteValue

public int getRandomDiscreteValue(int attributeId)

getContinuousAttributesIterator

public java.util.Iterator getContinuousAttributesIterator()
Returns an iterator on continuous attributes.

Returns:
an iterator on continuous attributes.

getPossibleDiscreteValues

public java.util.Collection getPossibleDiscreteValues(int attributeId)
Returns the possible values of a given discrete attribute.

Parameters:
attributeId - number id of the attribute.
Returns:
possible values for the given discrete attribute.

toString

public java.lang.String toString()
Transforms a ProblemDescription into String.

Overrides:
toString in class java.lang.Object