public class PrototypeGenerator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
algorithmName
Name of the reduction tecnique
|
protected PrototypeSet |
generatedDataSet
Condensed data
|
static long |
SEED
Default seed value to the Random Number Generator
|
long[] |
seedDefaultValueList
Default seed list to the Random Number Generator
|
protected PrototypeSet |
trainingDataSet
Original data set to be condensed
|
Constructor and Description |
---|
PrototypeGenerator(PrototypeSet _trainingDataSet)
Construct the PrototypeGenerator
|
PrototypeGenerator(PrototypeSet _trainingDataSet,
int seedIndex)
Construct the PrototypeGenerator
|
PrototypeGenerator(PrototypeSet _trainingDataSet,
Parameters parameters)
Construct the PrototypeGenerator
|
Modifier and Type | Method and Description |
---|---|
protected static int |
absoluteAccuracy(PrototypeSet condensed,
PrototypeSet test)
Calculate the absolute accuracy between two sets
|
protected static Pair<java.lang.Integer,java.lang.Integer> |
absoluteAccuracyAndError(PrototypeSet condensed,
PrototypeSet test)
Calculate the absolute accuracy between two sets
|
protected static int |
absoluteAccuracyKNN(PrototypeSet condensed,
PrototypeSet test,
int k)
Calculate the absolute accuracy between two sets
|
protected static double |
accuracy(PrototypeSet condensed,
PrototypeSet test)
Calculate the percetage of well classificated prototypes of one set using 1NN in a reduced set.
|
double |
accuracy2(PrototypeSet condensed,
PrototypeSet test)
Calculate the percetage of well classificated prototypes of one set using 1NN in a reduced set.
|
void |
desordenar_vector_sin(int[] vector)
Shuffles the values of the vector given as parameter, maintaining the last element value.
|
void |
desordenar_vector(int[] vector)
Shuffles the values of the vector given as parameter.
|
PrototypeSet |
execute()
Execute the reduction of the data set.
|
PrototypeSet |
generateReducedDataSet()
Execute the reduction of the data set
|
java.lang.String |
getResultingAccuracy(java.lang.String name,
int accuracy1NN,
PrototypeSet test)
Internal function that gets only the accuracy of the condensation.
|
java.lang.String |
getResultingAccuracy(java.lang.String name,
java.lang.String algoName,
int accuracy1NN,
PrototypeSet test)
Internal function that gets only the accuracy of the condensation.
|
java.lang.String |
getResults(java.lang.String name,
java.lang.String algoName,
int accuracy1NN,
int training_size,
PrototypeSet test)
Internal function that gets the parameters of accuracy of the condensation.
|
java.lang.String |
getResultsOfAccuracy(java.lang.String name,
int accuracy1NN,
PrototypeSet test)
Internal function that gets the parameters of accuracy of the condensation.
|
static java.lang.String |
getResultsOfAccuracy(java.lang.String name,
java.lang.String algorithmUsed,
PrototypeSet reduced,
PrototypeSet test)
Internal function that gets the parameters of accuracy of the condensation.
|
static long |
getSeed()
Get the seed of the random generator.
|
protected int |
getSetSizeFromPercentage(double percentage)
Number of prototypes corresponding of the desired percentage of the reduced set.
|
protected static int |
getSetSizeFromPercentage(PrototypeSet set,
double percentage)
Number of prototypes corresponding of the desired percentage of the reduced set.
|
long |
getTime()
Tell the time elapsed.
|
void |
inic_vector_sin(int[] vector,
int without)
Sets each position of the vector given as parameter with the i-th, skipping the position given as argument.
|
void |
inic_vector(int[] vector)
Sets each position of the vector given as parameter with the i-th number.
|
static void |
main(java.lang.String[] args)
General main for all the prototoype generators
Arguments:
0: Filename with the training data set to be condensed.
1: Filename wich will contain the test data set
3: k Number of neighbors used in the KNN function
|
PrototypeSet |
reduceSet()
Makes the trivial reduction.
|
void |
saveResultsOfAccuracyIn(java.lang.String name,
int accuracy1NN,
PrototypeSet test,
java.lang.String fileName)
Internal function that shows in the screen the parameters of accuracy of the condensation
|
static void |
saveResultsOfAccuracyIn(java.lang.String name,
java.lang.String algorithmUsed,
PrototypeSet reduced,
PrototypeSet test,
java.lang.String fileName,
boolean append)
Internal function that saves the parameters of accuracy of the condensation.
|
PrototypeSet |
selecRandomSet(int numberOfPrototypesSelected,
boolean usePriorProb)
Extract a random prototype set of the original traning data set.
|
static void |
setSeed(long _seed)
Set the seed of the random generator.
|
void |
showResultsOfAccuracy(int accuracyKNN,
int accuracy1NN,
int k,
PrototypeSet test)
Internal function that shows in the screen the parameters of accuracy of the condensation
|
void |
showResultsOfAccuracy(java.lang.String name,
int accuracy1NN,
PrototypeSet test)
Internal function that shows in the screen the parameters of accuracy of the condensation
|
protected PrototypeSet trainingDataSet
protected PrototypeSet generatedDataSet
protected java.lang.String algorithmName
public static long SEED
public final long[] seedDefaultValueList
public PrototypeGenerator(PrototypeSet _trainingDataSet)
_trainingDataSet
- Original data to be condensed.public PrototypeGenerator(PrototypeSet _trainingDataSet, int seedIndex)
_trainingDataSet
- Original data to be condensed.seedIndex
- Index of the seedDefaultValueListpublic PrototypeGenerator(PrototypeSet _trainingDataSet, Parameters parameters)
_trainingDataSet
- Original data to be condensed.parameters
- Parameters of the algorithm (the random seedDefaultValueList in [0])public static void setSeed(long _seed)
_seed
- Seed value.public static long getSeed()
public long getTime()
protected int getSetSizeFromPercentage(double percentage)
percentage
- Percentage of size that will have reduced set.protected static int getSetSizeFromPercentage(PrototypeSet set, double percentage)
set
- Original prototype set.percentage
- Percentage of size that will have reduced set.public PrototypeSet selecRandomSet(int numberOfPrototypesSelected, boolean usePriorProb)
numberOfPrototypesSelected
- Number of prototypes extracted.usePriorProb
- Use the a priori probabilites of the set.public PrototypeSet reduceSet()
public final PrototypeSet execute()
public PrototypeSet generateReducedDataSet()
protected static int absoluteAccuracy(PrototypeSet condensed, PrototypeSet test)
condensed
- Reduced data settest
- Test data setprotected static int absoluteAccuracyKNN(PrototypeSet condensed, PrototypeSet test, int k)
condensed
- Reduced data settest
- Test data setk
- number of neighbourprotected static double accuracy(PrototypeSet condensed, PrototypeSet test)
condensed
- Reduced data settest
- Test data setpublic double accuracy2(PrototypeSet condensed, PrototypeSet test)
condensed
- Reduced data settest
- Test data setprotected static Pair<java.lang.Integer,java.lang.Integer> absoluteAccuracyAndError(PrototypeSet condensed, PrototypeSet test)
condensed
- Reduced data settest
- Test data setpublic void showResultsOfAccuracy(int accuracyKNN, int accuracy1NN, int k, PrototypeSet test)
accuracyKNN
- Number of well-classificated prototypes with KNN.accuracy1NN
- Number of well-classificated prototypes with 1NN.k
- Number of neighbors in the KNN.test
- Test prototype set.public java.lang.String getResultsOfAccuracy(java.lang.String name, int accuracy1NN, PrototypeSet test)
name
- Name of the data set.accuracy1NN
- Number of well-classificated prototypes with KNN.test
- Test prototype set.public java.lang.String getResults(java.lang.String name, java.lang.String algoName, int accuracy1NN, int training_size, PrototypeSet test)
name
- Name of the data set.algoName
- Name of the algorithm.accuracy1NN
- Number of well-classificated prototypes with KNN.training_size
- Training dataset size (number of examples).test
- Test prototype set.public java.lang.String getResultingAccuracy(java.lang.String name, java.lang.String algoName, int accuracy1NN, PrototypeSet test)
name
- Name of the data set.algoName
- Algorithm name.accuracy1NN
- Number of well-classificated prototypes with KNN.test
- Test prototype set.public java.lang.String getResultingAccuracy(java.lang.String name, int accuracy1NN, PrototypeSet test)
name
- Name of the data set.accuracy1NN
- Number of well-classificated prototypes with KNN.test
- Test prototype set.public void showResultsOfAccuracy(java.lang.String name, int accuracy1NN, PrototypeSet test)
name
- Name of the data set.accuracy1NN
- Number of well-classificated prototypes with KNN.test
- Test prototype set.public void saveResultsOfAccuracyIn(java.lang.String name, int accuracy1NN, PrototypeSet test, java.lang.String fileName)
name
- Name of the data set.accuracy1NN
- Number of well-classificated prototypes with KNN.test
- Test prototype set.fileName
- Output file.public static java.lang.String getResultsOfAccuracy(java.lang.String name, java.lang.String algorithmUsed, PrototypeSet reduced, PrototypeSet test)
name
- Name of the data set.algorithmUsed
- Name of the algorithm used to reduce the set.reduced
- Reduced prototype set.test
- Test prototype set.public static void saveResultsOfAccuracyIn(java.lang.String name, java.lang.String algorithmUsed, PrototypeSet reduced, PrototypeSet test, java.lang.String fileName, boolean append)
name
- Name of the data set.algorithmUsed
- Name of the algorithm used to reduce the set.reduced
- Reduced prototype set.test
- Test prototype set.fileName
- File name that will contain the accuracy.append
- If is TRUE, appends the results to the output file; if is false rewrites the file with the new data.public void inic_vector(int[] vector)
vector
- vector to complete.public void inic_vector_sin(int[] vector, int without)
vector
- vector to complete.without
- position to skip.public void desordenar_vector_sin(int[] vector)
vector
- vector to shuffle.public void desordenar_vector(int[] vector)
vector
- vector to shuffle.public static void main(java.lang.String[] args)
args
- Arguments of the main function.