public class Instance
extends java.lang.Object
Instance
This class keeps all the information of an instance. It stores nominal, integer and real values read from the file (in KEEL format). Also, it provides a set of methods to get information about the instance.Modifier and Type | Field and Description |
---|---|
static int |
ATT_INPUT
Input attributes location
|
static int |
ATT_NONDEF
Non-defined direction attributes location
|
static int |
ATT_OUTPUT
Output attributes location
|
Constructor and Description |
---|
Instance(double[] values,
InstanceAttributes ats)
Creates an instance from a set of given values.
|
Instance(Instance inst)
Creates a deep copy of the Instance
|
Instance(java.lang.String def,
boolean _isTrain,
int instanceNum)
It parses a new attribute line.
|
Modifier and Type | Method and Description |
---|---|
boolean |
existsAnyMissingValue()
It returns if there is any missing value.
|
boolean |
existsInputMissingValues()
It informs about the existence of missing values in the inputs
|
boolean |
existsOutputMissingValues()
It informs about the existence of missing values in the outputs.
|
double[] |
getAllInputValues()
It does return all the input values.
|
double[] |
getAllOutputValues()
It does return all the output values.
|
boolean[] |
getInputMissingValues()
Get Input Missing Values
|
boolean |
getInputMissingValues(int pos)
Get Input Missing Values
|
java.lang.String[] |
getInputNominalValues()
Get Input Nominal Values
|
java.lang.String |
getInputNominalValues(int pos)
Get Input Nominal Values
|
int[] |
getInputNominalValuesInt()
It does return all the input nominal values.
|
int |
getInputNominalValuesInt(int pos)
It does return the input nominal value at the specified position.
|
double[] |
getInputRealValues()
Get Input Real Values
|
double |
getInputRealValues(int pos)
Get Input Real Values
|
double[] |
getNormalizedInputValues()
It does return the normalized values in a double[].
|
double[] |
getNormalizedInputValues(InstanceAttributes instAttributes)
Obtains the normalized input attributes from a InstanceAttribute definition
|
double[] |
getNormalizedOutputValues()
It does return the normalized values in a double[].
|
double[] |
getNormalizedOutputValues(InstanceAttributes instAttributes)
Obtains the normalized output attributes from a InstanceAttribute definition
|
boolean[] |
getOutputMissingValues()
Get Output Missing Values
|
boolean |
getOutputMissingValues(int pos)
Get Output Missing Values
|
java.lang.String[] |
getOutputNominalValues()
Get Output Nominal Values
|
java.lang.String |
getOutputNominalValues(int pos)
Get Output Nominal Values
|
int[] |
getOutputNominalValuesInt()
It does return the output value at the specified position
|
int |
getOutputNominalValuesInt(int pos)
It does return the output value at the specified position
|
double[] |
getOutputRealValues()
Get Output Real Values
|
double |
getOutputRealValues(int pos)
Get Output Real Values
|
void |
print()
It does print the instance information
|
void |
print(InstanceAttributes instAttributes)
It does print the instance information
|
void |
print(InstanceAttributes instAttributes,
java.io.PrintWriter out) |
void |
print(java.io.PrintWriter out)
It prints the instance to the specified PrintWriter.
|
void |
printAsOriginal(InstanceAttributes instAttributes,
java.io.PrintWriter out)
It prints the instance to the specified PrintWriter.
|
void |
printAsOriginal(java.io.PrintWriter out)
It prints the instance to the specified PrintWriter.
|
boolean |
setInputNominalValue(InstanceAttributes instAttributes,
int pos,
java.lang.String value)
Set a new value of a given input attribute in this instance (nominal)
|
boolean |
setInputNominalValue(int pos,
java.lang.String value)
It set the nominal attribute value to the one passed.
|
boolean |
setInputNumericValue(InstanceAttributes instAttributes,
int pos,
double value)
Set a new value of a given input attribute in this instance (integer or real)
|
boolean |
setInputNumericValue(int pos,
double value)
It changes the attribute value.
|
boolean |
setOutputNominalValue(InstanceAttributes instAttributes,
int pos,
java.lang.String value)
Set a new value of a given output attribute in this instance (nominal)
|
boolean |
setOutputNominalValue(int pos,
java.lang.String value)
It set the nominal attribute value to the one passed.
|
boolean |
setOutputNumericValue(InstanceAttributes instAttributes,
int pos,
double value)
Set a new value of a given output attribute in this instance (integer or real)
|
boolean |
setOutputNumericValue(int pos,
double value)
It changes the attribute value.
|
java.lang.String |
toString()
It does return an string with the instance information.
|
java.lang.String |
toString(InstanceAttributes instAttributes)
Prints the instance in KEEL format, according to the given Attributes definition
|
public static final int ATT_INPUT
public static final int ATT_OUTPUT
public static final int ATT_NONDEF
public Instance(java.lang.String def, boolean _isTrain, int instanceNum)
def
- is the line to be parsed._isTrain
- is a flag that indicates if the BD is for a train run.instanceNum
- is the number of the current instance. It's used to
write error message with the maximum amount of information.public Instance(Instance inst)
inst
- Original Instance to be copiedpublic Instance(double[] values, InstanceAttributes ats)
values
- A double array with the values (either real or nominals' index). Missing values are stored as Double.NaNats
- The definition of the attributes (optional, if null we use Attributes definition).public void print(java.io.PrintWriter out)
out
- is the PrintWriter where to print.public void printAsOriginal(java.io.PrintWriter out)
out
- is the PrintWriter where to print.public void print()
public double[] getInputRealValues()
public java.lang.String[] getInputNominalValues()
public boolean[] getInputMissingValues()
public double[] getOutputRealValues()
public java.lang.String[] getOutputNominalValues()
public boolean[] getOutputMissingValues()
public double getInputRealValues(int pos)
public java.lang.String getInputNominalValues(int pos)
public int getInputNominalValuesInt(int pos)
pos
- is the position.public int[] getInputNominalValuesInt()
public boolean getInputMissingValues(int pos)
public double getOutputRealValues(int pos)
public java.lang.String getOutputNominalValues(int pos)
public int getOutputNominalValuesInt(int pos)
pos
- is the position.public int[] getOutputNominalValuesInt()
public boolean getOutputMissingValues(int pos)
public double[] getAllInputValues()
public double[] getNormalizedInputValues()
public double[] getNormalizedOutputValues()
public double[] getAllOutputValues()
public boolean setInputNumericValue(int pos, double value)
pos
- is the attribute that has to be changedvalue
- is the new valuepublic boolean setOutputNumericValue(int pos, double value)
pos
- is the attribute that has to be changedvalue
- is the new valuepublic boolean setInputNominalValue(int pos, java.lang.String value)
pos
- is the position of the attribute.value
- is the new value.public boolean setOutputNominalValue(int pos, java.lang.String value)
pos
- is the position of the attribute.value
- is the new value.public boolean existsAnyMissingValue()
public boolean existsInputMissingValues()
public boolean existsOutputMissingValues()
public java.lang.String toString()
toString
in class java.lang.Object
public void print(InstanceAttributes instAttributes, java.io.PrintWriter out)
public void printAsOriginal(InstanceAttributes instAttributes, java.io.PrintWriter out)
out
- is the PrintWriter where to print.public void print(InstanceAttributes instAttributes)
public double[] getNormalizedInputValues(InstanceAttributes instAttributes)
instAttributes
- The Attributes definition needed to normalizepublic double[] getNormalizedOutputValues(InstanceAttributes instAttributes)
instAttributes
- The Attributes definition needed to normalizepublic boolean setInputNumericValue(InstanceAttributes instAttributes, int pos, double value)
instAttributes
- The Attributes reference definitionpos
- The position of the input attribute to be changed in instAttributesvalue
- The new valuepublic boolean setOutputNumericValue(InstanceAttributes instAttributes, int pos, double value)
instAttributes
- The Attributes reference definitionpos
- The position of the output attribute to be changed in instAttributesvalue
- The new valuepublic boolean setInputNominalValue(InstanceAttributes instAttributes, int pos, java.lang.String value)
instAttributes
- The Attributes reference definitionpos
- The position of the input attribute to be changed in instAttributesvalue
- The new valuepublic boolean setOutputNominalValue(InstanceAttributes instAttributes, int pos, java.lang.String value)
instAttributes
- The Attributes reference definitionpos
- The position of the output attribute to be changed in instAttributesvalue
- The new valuepublic java.lang.String toString(InstanceAttributes instAttributes)
instAttributes
- The reference Attributes definition for printing