public class Prototype
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DOUBLE
Double type of attributes.
|
protected int |
index
Index of the prototype in the set, used as an identifier.
|
protected double[] |
inputs
Normalized inputs of the prototype (values in [0,1]).
|
static int |
INTEGER
Integer type of attributes.
|
static int |
NOMINAL
Nominal type of attributes.
|
protected double[] |
outputs
Normalized outputs of the prototype (values in [0,1]).
|
protected static int[] |
type
Type of each attribute of the set.
|
static int |
UNKNOW_INDEX
Informs that the prototype has not got a definided index.
|
Constructor and Description |
---|
Prototype()
Constructs a null prototype.
|
Prototype(double[] inputs,
double[] outputs)
Constructs a Prototype.
|
Prototype(Instance inst)
Constructs a Prototype from an instance.
|
Prototype(int numInput,
int numOutput)
Parameter Constructor.
|
Prototype(Prototype original)
Constructs a Prototype from another protoype.
|
Modifier and Type | Method and Description |
---|---|
Prototype |
add(double increment)
Add an increment to all the inputs of the prototype
|
Prototype |
add(Prototype other)
Performs add operation between two prototypes.
|
Prototype |
addDiv(Prototype other,
double divisor)
Performs add and divide operation between two prototypes.
|
Prototype |
addMul(Prototype other,
double weight)
Performs add and product operation between two prototypes.
|
void |
applyThresholds()
Change attribute values that are not in [0.0, 1.0].
|
double |
assignedClass()
Returns the assigned class of the prototype (same value as the first output of the protoype).
|
Prototype |
avg(Prototype other)
Performs average operation between two prototypes.
|
static Prototype |
avg(Prototype p1,
double w1,
Prototype p2,
double w2)
Performs averaged-based explicit operation between two prototypes.
|
static Prototype |
avg(Prototype p1,
Prototype p2)
Performs average operation between two prototypes.
|
Prototype |
denormalize()
Denormalize the values of the inputs and outputs.
|
boolean |
equals(Prototype other)
Test if two prototypes are equals
|
boolean |
equalsInputs(Prototype other)
Test if two prototypes have the same inputs
|
double |
firstOutput()
Returns the first output of the protoype.
|
Prototype |
formatear()
Resets the prototype.
|
int |
getIndex()
Informs of the index of the prototype.
|
double |
getInput(int i)
Returns a specific input of the protoype.
|
java.lang.String |
getInputAsNominal(int i)
Return an input as nominal.
|
double[] |
getInputs()
Returns the inputs of the protoype.
|
double |
getOutput(int i)
Returns a specific output of the protoype.
|
java.lang.String |
getOutputAsNominal(int i)
Return an output as nominal.
|
double[] |
getOutputs()
Returns the outputs of the protoype.
|
static int |
getTypeOfAttribute(int i)
Return the type of the attribute.
|
double |
label()
Returns the label of the prototype (aka first output).
|
void |
makeNull()
Convert the prototype in the null prototype
|
double |
module()
Computes the module of a Prototype.
|
Prototype |
mul(double weight)
Performs product operation between one prototype and a double.
|
Prototype |
mul(Prototype other)
Multiply component by component like a scalar product.
|
double |
mulEscalar(Prototype other)
Multiplies component by component like a scalar product and sums the products.
|
protected static double |
normalize(double min,
double max,
double value)
Normalizes a given value using the maximum and minimum value given.
|
int |
numberOfInputs()
Returns the number of attributes that has an input.
|
int |
numberOfOutputs()
Returns the number of attributes that has an output.
|
Prototype |
opposite()
Computes inverse prototype, element by element. (1 - value)
|
static java.util.ArrayList<java.lang.Double> |
possibleValuesOfOutput()
Return all the existing classes in our universe.
|
void |
print()
Print the prototype.
|
protected static double |
round(double value)
Rounds a number given.
|
void |
set(Prototype original)
Copy the values of a Prototype from another protoype.
|
static void |
setAttributesTypes(InstanceAttributes att)
Update the type of each attribute of the set.
|
void |
setClass(double val)
Assigns a new class (aka new first output) to the prototype.
|
void |
setFirstOutput(double val)
Assigns a new value to the first output of the prototype.
|
void |
setIndex(int index)
Assigns a new index to the prototype.
|
void |
setInput(int i,
double valor)
Set a input for an attribute
|
void |
setLabel(double val)
Assigns a new label (aka first output, class) to the prototype.
|
Prototype |
sqrt()
Performs sqrt operation to all the inputs of the prototype.
|
Prototype |
sub(Prototype other)
Performs substract operation between two prototypes.
|
Prototype |
subMul(Prototype other,
double weight)
Performs substract and product operation between two prototypes.
|
java.lang.String |
toString()
Converts the prototype to a String object
|
public static final int UNKNOW_INDEX
protected int index
protected static int[] type
public static final int INTEGER
public static final int DOUBLE
public static final int NOMINAL
protected double[] inputs
protected double[] outputs
public Prototype()
public Prototype(int numInput, int numOutput)
numInput
- number of inputs.numOutput
- number of outputs.public Prototype(double[] inputs, double[] outputs)
inputs
- Inputs that will contain the new prototypeoutputs
- Ouputs that will contain the new prototypepublic Prototype(Instance inst)
inst
- Instance that contains inputs and outputs that will be assigned to the new prototype.public Prototype(Prototype original)
original
- Prototype that will be copied into the new object.protected static double normalize(double min, double max, double value)
min
- interval minimum value.max
- interval maximum value.value
- value to normalize.public static void setAttributesTypes(InstanceAttributes att)
att
- InstanceAttributes object.public static int getTypeOfAttribute(int i)
i
- ith attribute.public int getIndex()
public void setIndex(int index)
index
- New index to be assigned.public void set(Prototype original)
original
- Prototype that will be copied into the new object.public double[] getInputs()
public double getInput(int i)
i
- Index of the input attribute.public void setInput(int i, double valor)
i
- Index of the input attribute.valor
- Value to set.public double[] getOutputs()
public double getOutput(int i)
i
- Index of the output attribute.public double firstOutput()
public double label()
public double assignedClass()
public int numberOfInputs()
public void setFirstOutput(double val)
val
- Value to be assigned to the first output (aka label) of the prototype.public void setClass(double val)
val
- Value to be assigned to the first output (aka label) of the prototype.public void setLabel(double val)
val
- Value to be assigned to the first output (aka class) of the prototype.*public int numberOfOutputs()
public Prototype mul(Prototype other)
other
- prototype to multiply.public double mulEscalar(Prototype other)
other
- prototype to multiply.public Prototype mul(double weight)
weight
- Constant to be multiplied to each sum.public Prototype sqrt()
public double module()
public Prototype add(double increment)
increment
- public Prototype add(Prototype other)
other
- A protype to be added to the implicit parameter.public Prototype addMul(Prototype other, double weight)
other
- A protype to be added and multiplied to the implicit parameter.weight
- Constant to be multiplied to each sum.public Prototype addDiv(Prototype other, double divisor)
other
- A protype to be added and divided to the implicit parameter.divisor
- Constant that divides each sum.public Prototype avg(Prototype other)
other
- A protype to be merged to the implicit parameter.public static Prototype avg(Prototype p1, Prototype p2)
p1
- One protype to be merged.p2
- Other protype to be merged.public static Prototype avg(Prototype p1, double w1, Prototype p2, double w2)
p1
- One protype to be merged.w1
- Weight of prototype p1.p2
- Other protype to be merged.w2
- Weight of prototype p2.public Prototype sub(Prototype other)
other
- A protype to be substract to the implicit parameter.public Prototype subMul(Prototype other, double weight)
other
- A protype to be substract and multiplied to the implicit parameter.weight
- Constant to be multiplied to each difference.public java.lang.String toString()
toString
in class java.lang.Object
protected static double round(double value)
value
- given number to round.public Prototype denormalize()
public java.lang.String getInputAsNominal(int i)
i
- Index of the input.public java.lang.String getOutputAsNominal(int i)
i
- Index of the outut.public static java.util.ArrayList<java.lang.Double> possibleValuesOfOutput()
public boolean equals(Prototype other)
other
- The other prototype to be compared with the caller.public boolean equalsInputs(Prototype other)
other
- The other prototype to be compared with the caller.public void applyThresholds()
public void makeNull()
public void print()
public Prototype opposite()
public Prototype formatear()