public abstract class LazyAlgorithm
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int[][] |
confMatrix
Test Confusion matrix.
|
protected long |
initialTime
Initial time.
|
protected int |
inputAtt
Number of input attributes.
|
protected Attribute[] |
inputs
Inputs attributes.
|
protected double |
modelTime
Generation model time.
|
protected java.lang.String |
name
Naming.
|
protected int |
nClasses
Number of classes.
|
protected int[] |
nInstances
Number of instances of each classes.
|
protected boolean[] |
nulls
Missing values of a instance.
|
protected java.lang.String[] |
outFile
Output files names.
|
protected Attribute |
output
Output attribute.
|
protected int[][] |
prediction
Predited classes of the test instances.
|
int[] |
predictions
Class predictions for the examples.
|
double[][] |
probabilities
Class probabilities for the examples.
|
protected int[][] |
realClass
Real classes of the test instances.
|
protected InstanceSet |
reference
Reference dataset.
|
protected double[][] |
referenceData
Reference input data.
|
protected java.lang.String |
referenceFile
Reference file name.
|
protected int[] |
referenceOutput
Reference output data.
|
protected java.lang.String |
relation
Relation string.
|
protected long |
seed
Random seed.
|
protected Instance |
temp
Temporal instance.
|
protected InstanceSet |
test
Test dataset.
|
protected double[][] |
testData
Test input data.
|
protected java.lang.String |
testFile
Test file name.
|
protected int[] |
testOutput
Test output data.
|
protected double |
testTime
Test prediction time.
|
protected InstanceSet |
train
Training dataset.
|
protected int[][] |
trainConfMatrix
Training Confusion matrix.
|
protected double[][] |
trainData
Training input data.
|
protected java.lang.String |
trainFile
Train file name.
|
protected double |
trainingTime
Training prediction time.
|
protected int[] |
trainOutput
Training output data.
|
protected int[][] |
trainPrediction
Predited classes of the training instances.
|
protected int[][] |
trainRealClass
Real classes of the training instances.
|
protected int |
trainUnclassified
Number of unclassified training instances.
|
protected int |
unclassified
Number of unclassified test instances.
|
Constructor and Description |
---|
LazyAlgorithm() |
Modifier and Type | Method and Description |
---|---|
protected double |
euclideanDistance(double[] instance1,
double[] instance2)
Calculates the Euclidean distance between two instances
|
protected abstract int |
evaluate(double[] example)
Evaluates a instance to predict its class.
|
protected double[] |
evaluate2(double[] example)
Evaluates a instance to predict its class probabilities.
|
void |
execute()
Executes the classification of train and test data sets
|
void |
executeReference()
Executes the classification of reference and test data sets
|
protected double |
manhattanDistance(double[] instance1,
double[] instance2)
Calculates the Manhattan distance between two instances
|
protected void |
normalizeReference()
This function builds the data matrix for reference data and normalizes inputs values
|
protected void |
normalizeTest()
This function builds the data matrix for test data and normalizes inputs values
|
protected void |
normalizeTrain()
This function builds the data matrix for training data and normalizes inputs values
|
static java.lang.String |
printInstance(int[] instance)
Generates a string with the contents of the instance
|
protected void |
readConfiguracion(java.lang.String script)
Reads configuration script, and extracts its contents.
|
protected void |
readDataFiles(double[][] train,
int[] clasesTrain,
double[][] test,
int[] clasesTest,
int clases)
Set the training and the test dataset with their classes given as argument.
|
protected void |
readDataFiles(java.lang.String script)
Read the configuration and data files, and process it.
|
protected void |
readDataFiles(java.lang.String script,
InstanceSet train,
InstanceSet test,
InstanceSet reference)
Read the configuration and data files, process it.
|
protected abstract void |
readParameters(java.lang.String script)
Reads the parameters of the algorithm.
|
protected boolean |
same(double[] a,
double[] b)
Checks if two instances are the same
|
protected void |
setInitialTime()
Sets the time counter
|
protected java.lang.String[] outFile
protected java.lang.String testFile
protected java.lang.String trainFile
protected java.lang.String referenceFile
protected InstanceSet train
protected InstanceSet test
protected InstanceSet reference
protected Instance temp
protected int inputAtt
protected Attribute[] inputs
protected Attribute output
protected boolean[] nulls
protected double[][] trainData
protected int[] trainOutput
protected double[][] testData
protected int[] testOutput
protected double[][] referenceData
protected int[] referenceOutput
protected java.lang.String relation
public int[] predictions
public double[][] probabilities
protected int nClasses
protected int[] nInstances
protected long initialTime
protected double modelTime
protected double trainingTime
protected double testTime
protected java.lang.String name
protected long seed
protected int[][] confMatrix
protected int unclassified
protected int[][] realClass
protected int[][] prediction
protected int[][] trainConfMatrix
protected int trainUnclassified
protected int[][] trainRealClass
protected int[][] trainPrediction
protected void readDataFiles(double[][] train, int[] clasesTrain, double[][] test, int[] clasesTest, int clases)
train
- training dataset given.clasesTrain
- training examples classes.test
- test dataset given.clasesTest
- test examples classes.clases
- number of classes.protected void readDataFiles(java.lang.String script, InstanceSet train, InstanceSet test, InstanceSet reference)
script
- Name of the configuration scripttrain
- training dataset given as InstanceSet
object.test
- test dataset given as InstanceSet
object.reference
- reference dataset given as InstanceSet
object.protected void readDataFiles(java.lang.String script)
script
- Name of the configuration scriptprotected void readConfiguracion(java.lang.String script)
script
- Name of the configuration scriptprotected abstract void readParameters(java.lang.String script)
script
- Configuration scriptprotected void normalizeTrain() throws DataException
DataException
- if the dataset is not appropriate for problem.protected void normalizeTest() throws DataException
DataException
- if the dataset is not appropriate for problem.protected void normalizeReference() throws DataException
DataException
- if the dataset is not appropriate for problem.public void execute()
public void executeReference()
protected abstract int evaluate(double[] example)
example
- Instance evaluatedprotected double[] evaluate2(double[] example)
example
- Instance evaluatedprotected double euclideanDistance(double[] instance1, double[] instance2)
instance1
- First instanceinstance2
- Second instanceprotected double manhattanDistance(double[] instance1, double[] instance2)
instance1
- First instanceinstance2
- Second instanceprotected boolean same(double[] a, double[] b)
a
- First instanceb
- Second instancepublic static java.lang.String printInstance(int[] instance)
instance
- Instance to print.protected void setInitialTime()