public class Attribute
extends java.lang.Object
initialValue
, is a pattern for all the fields.
If the domain is consisted of numbers, you can define discretization intervals
to split the domain of the attribute.
It is very useful when you want to make one value from a group.
If you want to discriminate examples, specify the attribute's preference type (gain or cost).
There is also a special kind of the attribute. It is called "membership"
and says what is a possibility that the example is the right one. For instance,
we want to know which one is closer to "citrus fruits": an apple, an orange, a car or a chair.
Remember that membership can be set true
only when the field is derived from FloatField
.Modifier and Type | Field | Description |
---|---|---|
static int |
COST |
This is a type of preference.
|
static int |
DECISION |
It denotes a special kind of column: a classification of examples.
|
static int |
DESCRIPTION |
Assign to
kind when the attribute describes examples. |
static int |
GAIN |
Applies to preference type.
|
static int |
NONE |
It is stored when no kind of the attribute or preference type is assigned.
|
Constructor | Description |
---|---|
Attribute(java.lang.String name,
Field initialValue) |
Creates an active attribute with reference to a default field.
|
Modifier and Type | Method | Description |
---|---|---|
void |
copy(Attribute attribute) |
Takes all values from another attribute.
|
boolean |
getActive() |
Checks if attribute is visible in decision table.
|
Discretization |
getDiscretization() |
Get the list of intervals connected with discretization of the domain.
|
Field |
getInitialValue() |
Returns a field, which is created in new examples.
|
int |
getKind() |
Gets the kind of attribute.
|
boolean |
getMembership() |
Checks if attribute contains "membership" information.
|
java.lang.String |
getName() |
Returns the name of the attribute.
|
int |
getPreferenceType() |
Returns type of preference assigned to the attribute.
|
void |
setActive(boolean active) |
Sets the visibility of this attribute in decision table.
|
void |
setDiscretization(Discretization discretization) |
Assigns list of intervals associated with the domain discretization.
|
void |
setInitialValue(Field initialValue) |
Sets initial value of this attribute
|
void |
setKind(int kind) |
Assigns the interpretation of data in column.
|
void |
setMembership(boolean membership) |
Describes a special information meaning on values in column.
|
void |
setName(java.lang.String name) |
Sets an id for attribute.
|
void |
setPreferenceType(int type) |
Assigns type of preference for values stored in the domain.
|
java.lang.String |
toString() |
Returns a
String which represents this attribute. |
public static final int NONE
public static final int GAIN
public static final int COST
public static final int DECISION
public static final int DESCRIPTION
kind
when the attribute describes examples.public Attribute(java.lang.String name, Field initialValue)
NONE
as default).
Membership is set to false and discretization to null.
There is specified pattern for name (look at setName
method).
Given field is a type pattern. It is directly stored in the attribute (without duplicating).name
- name of the created attributeinitialValue
- field, which is used as type pattern (cannot be empty)InvalidValueException
- if name doesn't match the patternjava.lang.NullPointerException
- when name or field is nullpublic void copy(Attribute attribute)
attribute
- reference of attribute to copy values fromInvalidTypeException
- if initial field is incorrect typejava.lang.NullPointerException
- when given field is nullpublic Field getInitialValue()
public java.lang.String getName()
public void setName(java.lang.String name)
[A-Za-z_][A-Za-z_0-9]*
and cannot be null.name
- string for new name of attributeInvalidValueException
- if name doesn't match the patternjava.lang.NullPointerException
- when given name is nullpublic int getPreferenceType()
GAIN
/COST
/NONE
public void setPreferenceType(int type)
type
- one of the following:GAIN
the greater value the more usefulCOST
reverse to the above oneNONE
no specific type of preferencepublic boolean getActive()
true
if column should be shown, false
otherwisepublic void setActive(boolean active)
active
- logical value means if column should be shownpublic int getKind()
NONE
/DESCRIPTION
/DECISION
public void setKind(int kind)
kind
- on of the following:DECISION
column contains a classification of examplesDESCRIPTION
fields are names of examplesNONE
otherwisepublic boolean getMembership()
true
values have special meaning, false
otherwisepublic void setMembership(boolean membership)
true
can be set only when initial value
is FloatField
(or derived).
Otherwise, you won't set membership status, because of type.membership
- true
when you want to assign membership meaning to the attributeConsistencyException
- if initial value is not derived from FloatField
public Discretization getDiscretization()
public void setDiscretization(Discretization discretization)
discretization
- object containing the listpublic java.lang.String toString()
String
which represents this attribute.
It contains activity, name and type.toString
in class java.lang.Object
public void setInitialValue(Field initialValue)
initialValue
- initial value of this attribute