cosc575.p1
Class Attributes

java.lang.Object
  extended by cosc575.p1.Attributes

public class Attributes
extends java.lang.Object

Stores the attributes information for data sets for machine learning.


Field Summary
private  java.util.ArrayList<Attribute> attributes
          a list of attribute names
private  int classIndex
          stores the position of the class label
(package private)  boolean hasDiscreteAttributes
          a flag indicating that the data set has one or more discrete attributes
(package private)  boolean hasNominalAttributes
          a flag indicating that the data set has one or more nominal attributes
(package private)  boolean hasNumericAttributes
          a flag indicating that the data set has one or more numeric attributes
 
Constructor Summary
Attributes()
          Default constructor.
Attributes(java.util.Scanner scanner)
          Explicit constructor.
 
Method Summary
 void add(Attribute attribute)
          Adds a new attribute to this set of attributes.
 Attribute get(int i)
          Returns the ith attribute in this set of attributes.
 Attribute getClassAttribute()
          Returns the class attribute.
 int getClassIndex()
          Returns the index of the class label.
 boolean getHasDiscreteAttributes()
          Returns true if this set of attributes has one or more discrete attributes; returns false otherwise.
 boolean getHasNominalAttributes()
          Returns true if this set of attributes has one or more nominal attributes; returns false otherwise.
 boolean getHasNumericAttributes()
          Returns true if this set of attributes has one or more numeric attributes; returns false otherwise.
 int getIndex(java.lang.String name)
          Returns the attribute's index.
 int getSize()
          Returns the number of attributes.
private  void initialize()
          Initializes the names, types, and domains lists.
static void main(java.lang.String[] args)
           
private  void parse(java.util.Scanner scanner)
          Parses the attribute declarations in the specified scanner.
 void setClassIndex(int classIndex)
          Sets the class index for this set of attributes.
 java.lang.String toString()
          Returns a string representation of the names structure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attributes

private java.util.ArrayList<Attribute> attributes
a list of attribute names


hasNumericAttributes

boolean hasNumericAttributes
a flag indicating that the data set has one or more numeric attributes


hasNominalAttributes

boolean hasNominalAttributes
a flag indicating that the data set has one or more nominal attributes


hasDiscreteAttributes

boolean hasDiscreteAttributes
a flag indicating that the data set has one or more discrete attributes


classIndex

private int classIndex
stores the position of the class label

Constructor Detail

Attributes

Attributes()
Default constructor.


Attributes

Attributes(java.util.Scanner scanner)
     throws java.lang.Exception
Explicit constructor. Creates a data set populated with the tokens in the scanner.

Parameters:
scanner - a Scanner containing the data set's tokens
Throws:
java.lang.Exception - if an exception occurs
Method Detail

initialize

private void initialize()
Initializes the names, types, and domains lists.


getClassIndex

public int getClassIndex()
Returns the index of the class label.

Returns:
the index of the class label

setClassIndex

public void setClassIndex(int classIndex)
                   throws java.lang.Exception
Sets the class index for this set of attributes.

Parameters:
classIndex - the new class index
Throws:
java.lang.Exception - if an exception occurs

getHasNumericAttributes

public boolean getHasNumericAttributes()
Returns true if this set of attributes has one or more numeric attributes; returns false otherwise.

Returns:
true if this set of attributes has numeric attributes

getHasDiscreteAttributes

public boolean getHasDiscreteAttributes()
Returns true if this set of attributes has one or more discrete attributes; returns false otherwise.

Returns:
true if this set of attributes has discrete attributes

getHasNominalAttributes

public boolean getHasNominalAttributes()
Returns true if this set of attributes has one or more nominal attributes; returns false otherwise.

Returns:
true if this set of attributes has nominal attributes

get

public Attribute get(int i)
              throws java.lang.Exception
Returns the ith attribute in this set of attributes.

Parameters:
i - the index of the specified attribute
Returns:
the ith Attribute
Throws:
java.lang.Exception - if an exception occurs

getClassAttribute

public Attribute getClassAttribute()
                            throws java.lang.Exception
Returns the class attribute.

Returns:
the class attribute
Throws:
java.lang.Exception - if an exception occurs

getSize

public int getSize()
Returns the number of attributes.

Returns:
the number of attributes

getIndex

public int getIndex(java.lang.String name)
             throws java.lang.Exception
Returns the attribute's index.

Parameters:
name - the attribute's name
Returns:
the attribute's position in the names array
Throws:
java.lang.Exception - if an exception occurs

add

public void add(Attribute attribute)
         throws java.lang.Exception
Adds a new attribute to this set of attributes.

Parameters:
attribute - the attribute's name
Throws:
java.lang.Exception - if an exception occurs

parse

private void parse(java.util.Scanner scanner)
            throws java.lang.Exception
Parses the attribute declarations in the specified scanner.

Parameters:
scanner - a Scanner containing the data set's tokens
Throws:
java.lang.Exception - if an exception occurs

toString

public java.lang.String toString()
Returns a string representation of the names structure.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the names structure

main

public static void main(java.lang.String[] args)