public class Attribute
extends java.lang.Object
Attribute
It contains an attribute representation. The class attributes are enough to descrive completly an attribute: name, type, possible values, minimums and maximums, etc. It offers a collection of functions to get all this information.Modifier and Type | Field and Description |
---|---|
static int |
DIR_NOT_DEF
Label to identify attributes that hasn't been defined neither as input or output
|
static int |
INPUT
Label to identify INPUT attributes
|
static int |
INTEGER
Label for INTEGER values.
|
static int |
NOMINAL
Label for NOMINAL values.
|
static int |
OUTPUT
Label to identify OUTPUT attributes
|
static int |
REAL
Label for REAL VALUES
|
Constructor and Description |
---|
Attribute()
Attribute Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addInMeanValue(int whichClass,
double value)
It adds the new value to the mean values vector
|
void |
addNominalValue(java.lang.String value)
This method add a new value to the list of possible values in a nominal
attribute.
|
boolean |
addTestNominalValue(java.lang.String value)
Adds a new value for a nominal that has been read in the test file.
|
boolean |
areNewNominalValuesInTest()
It returns true if in test have appeared new values.
|
int |
convertNominalValue(java.lang.String value)
It converts a nominal value to a integer
|
void |
enlargeBounds(double value)
It does enlarge the attribute bounds
|
boolean |
equals(Attribute attr)
It compares two attributes.
|
int |
getDirectionAttribute()
It returns if the attribute is an input attribute
|
boolean |
getFixedBounds()
It returns the variable fixedBounds.
|
double |
getMaxAttribute()
It returns the maximum possible value in a integer or real attribute
|
double |
getMeanValue(int whichClass)
Does return the mean value for that attribute.
|
double |
getMinAttribute()
It returns the minimum possible value in a integer or real attribute
|
java.lang.String |
getMostFrequentValue(int whichClass)
It does return the value most frequent for the class
|
java.lang.String |
getName()
It gets the attribute name
|
java.util.Vector |
getNewValuesInTest()
It returns a vector with all new nominal values read in test.
|
java.lang.String |
getNominalValue(int pos)
It returns de ith value of that nominal attribute
|
java.util.Vector |
getNominalValuesList()
Returns all the possible nominal values
|
int |
getNumNominalValues()
It returns the number of different values that can take a nominal attribute.
|
int |
getType()
It does return the type of the attribute
|
boolean |
isInBounds(double val)
It does check if the value passed as an argument is bounded by
the [min, max] interval.
|
boolean |
isNominalValue(java.lang.String val)
It returns if the value passed is in the list of nominal values
|
double |
normalizeValue(double val)
It does normalize a value.
|
void |
print()
This method prints the attribute information.
|
double |
rectifyValueInBounds(double value)
It update an integer or real value read for an attribute in the test
set if it doesn't match with the bounds defined in the train set.
|
void |
setBounds(double _min,
double _max)
It sets the bound of the integer or real attribute.
|
void |
setDirectionAttribute(int _dirAtt)
It sets if the attribute is an input or an output attribute
|
void |
setFixedBounds(boolean fBounds)
It sets the fixedBounds value
|
void |
setName(java.lang.String _name)
It sets the attribute name
|
void |
setType(int _type)
It sets the attribute type.
|
java.lang.String |
toString()
It returns a String with the attribute information in keel format
|
public static final int NOMINAL
public static final int INTEGER
public static final int REAL
public static final int INPUT
public static final int OUTPUT
public static final int DIR_NOT_DEF
public Attribute()
public void setType(int _type)
_type
- given attribute typepublic int getType()
public void setName(java.lang.String _name)
_name
- is the name to be set.public java.lang.String getName()
public void setBounds(double _min, double _max)
_min
- is the minimum value that the attribute can take._max
- is the maximum value that the attribute can take.public boolean getFixedBounds()
public void setFixedBounds(boolean fBounds)
fBounds
- is the value that has to be fixed to fixedBounds.public void enlargeBounds(double value)
value
- is the value read from the BD filepublic double rectifyValueInBounds(double value)
value
- is the value read from the test file.public boolean isInBounds(double val)
val
- value to check.public boolean isNominalValue(java.lang.String val)
val
- is the value to be checked.public double getMinAttribute()
public double getMaxAttribute()
public void addNominalValue(java.lang.String value)
value
- is the new value to be added.public java.lang.String getMostFrequentValue(int whichClass)
whichClass
- is the class which is wanted to know the most
frequent value.public double getMeanValue(int whichClass)
whichClass
- is the integer value for the classpublic void addInMeanValue(int whichClass, double value)
whichClass
- is the class where to add the new valuevalue
- is the value to be added.public boolean addTestNominalValue(java.lang.String value)
value
- is the new value to be added.public java.util.Vector getNewValuesInTest()
public boolean areNewNominalValuesInTest()
public int getNumNominalValues()
public java.util.Vector getNominalValuesList()
public java.lang.String getNominalValue(int pos)
pos
- indicate which attribute value is wanted.public int convertNominalValue(java.lang.String value)
value
- is the value that is wanted to be convertedpublic boolean equals(Attribute attr)
attr
- is the second attribute of the comparation.public void setDirectionAttribute(int _dirAtt)
_dirAtt
- is the direction (input/output) of the attribute.public int getDirectionAttribute()
public double normalizeValue(double val)
val
- is the value to be normalized.public java.lang.String toString()
toString
in class java.lang.Object
public void print()