public class PrototypeGenerator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
algorithmName
Name of the reduction tecnique
|
protected Pair<PrototypeSet,PrototypeSet> |
generatedDataSet
Condensed data
|
static InstanceSet |
Instancetest
Original test data set to be condensed
|
static InstanceSet |
Instancetrain
Original training data set to be condensed
|
static long |
SEED
Default seed value to the Random Number Generator
|
long[] |
seedDefaultValueList
Default seed list to the Random Number Generator
|
protected PrototypeSet |
testDataSet
Test prototype set.
|
protected PrototypeSet |
trainingDataSet
Training prototype set.
|
protected PrototypeSet |
transductiveDataSet
Transductive prototype set.
|
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
|
PrototypeGenerator(PrototypeSet _trainingDataSet,
PrototypeSet _testDataSet,
Parameters parameters)
Construct the PrototypeGenerator for Supervised Learning (pos-processing)
|
PrototypeGenerator(PrototypeSet _trainingDataSet,
PrototypeSet _unlabeledDataSet,
PrototypeSet _testDataSet,
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.
|
Pair<PrototypeSet,PrototypeSet> |
applyAlgorithm()
Makes the trivial reduction.
|
void |
desordenar_vector_sin(int[] vector)
Cuando quitas uno, con el inic vector, el desordenar no puede coger el ultimo..
|
void |
desordenar_vector(int[] vector)
Shuffles the vector given.
|
Pair<PrototypeSet,PrototypeSet> |
execute()
Execute the reduction of the data set.
|
Pair<PrototypeSet,PrototypeSet> |
generateReducedDataSet()
Execute the reduction of the data set
|
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.
|
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)
Initiates the vector given without the index given.
|
void |
inic_vector(int[] vector)
Initiates the vector given.
|
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
|
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 |
setInstanceTest(InstanceSet uno)
Sets the test instances set given.
|
static void |
setInstanceTrain(InstanceSet uno)
Sets the training instances set given.
|
static void |
setSeed(long _seed)
Set the seed of the random generator.
|
public static InstanceSet Instancetrain
public static InstanceSet Instancetest
protected PrototypeSet trainingDataSet
protected PrototypeSet transductiveDataSet
protected PrototypeSet testDataSet
protected Pair<PrototypeSet,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 PrototypeGenerator(PrototypeSet _trainingDataSet, PrototypeSet _testDataSet, Parameters parameters)
_trainingDataSet
- Original data to be condensed._testDataSet
- Original test prototype set.parameters
- Parameters of the algorithm (the random seedDefaultValueList in [0])public PrototypeGenerator(PrototypeSet _trainingDataSet, PrototypeSet _unlabeledDataSet, PrototypeSet _testDataSet, Parameters parameters)
_trainingDataSet
- Original data to be condensed._unlabeledDataSet
- Original unlabeled prototype set for SSL._testDataSet
- Original test prototype set.parameters
- Parameters of the algorithm (the random seedDefaultValueList in [0])public static void setSeed(long _seed)
_seed
- Seed value.public static void setInstanceTrain(InstanceSet uno)
uno
- the training instances set to set.public static void setInstanceTest(InstanceSet uno)
uno
- the test instances set to set.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 Pair<PrototypeSet,PrototypeSet> applyAlgorithm() throws java.lang.Exception
java.lang.Exception
- if the algorithm can not be applied.public final Pair<PrototypeSet,PrototypeSet> execute() throws java.lang.Exception
java.lang.Exception
- if the algorithm can not be executed.public Pair<PrototypeSet,PrototypeSet> generateReducedDataSet() throws java.lang.Exception
java.lang.Exception
- if the reduction can not be done.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 nearest neighbours considered.protected 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 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 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
- given vector to initiatespublic void inic_vector_sin(int[] vector, int without)
vector
- given vector to initiateswithout
- index given.public void desordenar_vector_sin(int[] vector)
vector
- public void desordenar_vector(int[] vector)
vector
- given vector to shuffles.public static void main(java.lang.String[] args)
args
- Arguments of the main function.