public class PrototypeSet extends java.util.ArrayList<Prototype> implements java.lang.Comparable
Modifier and Type | Field and Description |
---|---|
static InstanceSet |
associatedInstanceSet
Associated instance set to the prototype set.
|
protected static java.util.ArrayList<java.lang.Integer> |
FeaturesSet1
Features set 1.
|
protected static java.util.ArrayList<java.lang.Integer> |
FeaturesSet2
Features set 2.
|
Constructor and Description |
---|
PrototypeSet()
Empty constructor
|
PrototypeSet(java.util.ArrayList<PrototypeSet> parts)
Build a set using a partition of other.
|
PrototypeSet(InstanceSet s)
Constructs the set based on a instance set
|
PrototypeSet(int numberOfElements)
Constructs a void set with a number of elements.
|
PrototypeSet(PrototypeSet original)
Copy constructor.
|
PrototypeSet(PrototypeSet source,
int first,
int toCopy)
Creates a new set of instances by copying a
subset of another set.
|
Modifier and Type | Method and Description |
---|---|
void |
add(PrototypeSet other)
Add the elements of a set.
|
void |
addNoRepetition(PrototypeSet other)
Add the elements of a set.
|
void |
addPrototype(Prototype other)
Add one prototype to the set..
|
PrototypeSet |
addPrototype2(Prototype other)
this + other.
|
void |
addPrototypeNoRepetition(Prototype other) |
Pair<Prototype,java.lang.Double> |
antiRadius(Prototype center)
Returns the smallest distance between center and other prototype and that prototype.
|
void |
applyThresholds()
Change values of the prototypes that are not in the values domain.
|
java.lang.String |
asKeelDataFileString()
Converts data set into a Keelish-String.
|
java.lang.String |
asKeelDataFileString(java.lang.String title)
Converts data set into a Keelish-String.
|
Prototype |
avg()
Performs avg operation of the prototype set.
|
Prototype |
borrar(int index)
Returns a copy of the set without an prototype.
|
java.util.ArrayList<java.lang.Double> |
classesWithPrototypes()
Returns classes which there are prototypes with them.
|
java.util.ArrayList<PrototypeSet> |
classPartition()
Makes a partition of the set by class.
|
PrototypeSet |
clone()
Override of the clone function
|
int |
compareTo(java.lang.Object o1) |
Prototype |
containing(Prototype current)
Return the prototype containing N from this set.
|
boolean |
containsSeveralClasses()
Informs if the set contains prototypes with several different classes.
|
PrototypeSet |
copy()
Hard-copy of the prototype set.
|
java.util.HashMap<java.lang.Double,java.lang.Integer> |
countPrototypesOfEachOutput()
Count the number of prototypes of each class.
|
Pair<PrototypeSet,PrototypeSet> |
divideFeaturesRandomly()
This method divides the PrototypeSet into two different prototypesets where the original attributes sets are randomly partititoned, with similar sizes.
|
PrototypeSet[] |
divideFeaturesRandomly(int[][] indices)
This method divides the features based on the indexes parameters
|
PrototypeSet[] |
divideFeaturesRandomly(int subspaces,
int dimension,
int[][] indices)
This method divides the datasets into X subspaces of dimension ''dimension''.
|
void |
doubleToprototypeSet(double[][] datos,
int clase)
PrototypeSet to double.
|
Pair<Prototype,Prototype> |
farthestPrototypes()
Returns the two nearest to each other prototypes
|
Prototype |
farthestTo(Prototype current)
Return the farthest prototype to another in the set.
|
void |
formatear(PrototypeSet initial) |
PrototypeSet |
getAllDifferentFromClass(double _class)
Select all the patterns of different classs.
|
PrototypeSet |
getFeatures(java.util.ArrayList<java.lang.Integer> lista)
It return the prototypeset with the features specified in lista.
|
java.util.ArrayList<java.lang.Integer> |
getFeatures1() |
java.util.ArrayList<java.lang.Integer> |
getFeatures2() |
java.util.HashMap<java.lang.Double,java.lang.Integer> |
getFrequencyOfClasses()
Inform the frequency of each class of the set
|
PrototypeSet |
getFromClass(double _class)
Select all the prototypes of a specific class.
|
java.util.ArrayList<java.lang.Double> |
getPosibleValuesOfOutput()
Return all the existing classes in our universe.
|
Prototype |
getRandom()
Get a random prototype
|
boolean |
homogeneity() |
int |
IndexNearestTo(Prototype current)
Return the INDEX off nearest prototype to another in the set.
|
int |
IndexSecondNearestTo(Prototype current)
Return the INDEX of the Second closest prototype to another in the set.
|
PrototypeSet |
isTheNearPrototype(Prototype other)
Return all the prototype in (this) that has other like the nearest neighbor
|
PrototypeSet |
isTheNearPrototypeWithClass(Prototype other,
double clase)
Return all the prototype in (this) that has other like the nearest neighbor with the class given.
|
PrototypeSet |
join(Prototype other)
Join a prototype to a set
|
double |
largestDiameter()
Size of the greatest diameter in the set.
|
Pair<PrototypeSet,PrototypeSet> |
makePartition(double percentInFirst)
Makes a partition of the set.
|
Pair<PrototypeSet,PrototypeSet> |
makePartitionPerClass(double percentInFirst)
Makes a partition of the set.
|
double |
maxDistanceTo(Prototype center)
Returns the greatest distance between center.
|
double |
minDist(Prototype uno)
return the smallest distance between uno and all prototypes of the particle.
|
double |
minDistanceTo(Prototype center)
Returns the smallest distance between center and other prototype and that prototype.
|
Pair<Prototype,java.lang.Double> |
minimumLengthAndNearestTo(Prototype current)
Return the nearest prototype to another in the set.
|
Pair<Prototype,java.lang.Double> |
minimumLengthAndNearestWithSameClassAs(Prototype current)
Return the nearest prototype to another in the set.
|
PrototypeSet |
minus(PrototypeSet other)
Returns a copy of the set without an element.
|
double |
mostFrequentClass()
Returns the most frequent class
|
PrototypeSet |
mulEscalar(double escalar)
Multiplicar un conjunto por un Escalar.
|
Pair<Prototype,Prototype> |
nearestPair()
Returns the nearest pair of prototypes of the set.
|
Prototype |
nearestTo(Prototype current)
Return the nearest prototype to another in the set.
|
Prototype |
nearestTo(PrototypeSet current)
Return the nearest prototype to all the prototypes of a set.
|
Prototype |
nearestToWithClass(Prototype current,
double label)
Return the nearest prototype to another in the set with a specified class.
|
Prototype |
nearestToWithDifferentClass(Prototype current,
double label)
Return the nearest prototype to another in the set with a specified class.
|
java.util.ArrayList<java.lang.Double> |
nonVoidClasses()
Return classes with at least one element.
|
PrototypeSet |
opposite()
Calculaa el opuesto de un conjunto .
|
double |
Overlapping()
This method return the ratio of the average distance between instances blongin to different classes of i
and the average distance between instances that are from the same class i.
|
java.util.ArrayList<PrototypeSet> |
partIn(int numberOfSets)
Make a partition of a set. numberOfSets sets with the same number of prototypes will be generated.
|
Pair<PrototypeSet,PrototypeSet> |
partIntoSubsetsOverlappingDegree(Pair<Prototype,Prototype> pair)
Generate two subsets of the set t.
|
Pair<PrototypeSet,PrototypeSet> |
partIntoSubsetsOverlappingDegree(Prototype p1,
Prototype p2)
Generate two subsets of the set t.
|
Pair<PrototypeSet,PrototypeSet> |
partIntoSubsetsWhichSeedPointsAre(Pair<Prototype,Prototype> pair)
Generate two subsets of the set t.
|
Pair<PrototypeSet,PrototypeSet> |
partIntoSubsetsWhichSeedPointsAre(Prototype p1,
Prototype p2)
Generate two subsets of the set t.
|
protected int |
partition(int attIndex,
int l,
int r)
Partitions the instances around a pivot.
|
boolean |
pertenece(Prototype other)
Comprueba si existen en el conjunto....
|
boolean |
perteneceSinClass(Prototype other) |
void |
print()
Prints the prototype in the terminal
|
void |
printSet()
Print Prototype Set.
|
int[] |
prototypeSetClasses() |
double[][] |
prototypeSetTodouble()
PrototypeSet to double.
|
java.util.ArrayList<java.lang.Integer> |
quicksort(java.util.ArrayList<java.lang.Integer> numbers)
Sorted a ArrayList of Integers
|
protected void |
quickSort(int attIndex,
int left,
int right)
Implements quicksort according to Manber's "Introduction to
Algorithms".
|
Pair<Prototype,java.lang.Double> |
radius(Prototype center)
Returns the greatest distance between center and other prototype and that prototype.
|
void |
randomize()
Shuffle the set.
|
void |
randomize(long shuffleSeed)
Shuffle the set.
|
boolean |
remove(Prototype other)
Returns a copy of the set without an prototype.
|
boolean |
remove(PrototypeSet other)
Returns a copy of the set without an prototype.
|
Prototype |
removeRandom()
Remove a random prototype (and returns it)
|
boolean |
removeWithoutClass(Prototype other)
Returns a copy of the set without an prototype without checking the class label
|
boolean |
removeWithoutClass(PrototypeSet other) |
PrototypeSet |
resample()
Return a prototype set by Bootstrapping the current PrototypeSet
Creates a new dataset of the same size using random sampling
with replacement according to the given weight vector.
|
PrototypeSet |
restar(PrototypeSet other)
Restar dos conjuntos de prototipos , uno a uno.
|
void |
save(java.lang.String filename)
Save the data in a file (Keel style)
|
Prototype |
sd()
Performs standard desviation operation of the prototype set.
|
void |
sort(int attIndex)
Sorts the instances based on an attribute.
|
PrototypeSet |
sort(Prototype current)
Sort the prototype set in ascending distance to current prototype.
|
void |
stratify(int numFolds)
Stratifies a set of instances according to its class values
if the class attribute is nominal (so that afterwards a
stratified cross-validation can be performed).
|
protected void |
stratStep(int numFolds)
Help function needed for stratification of set.
|
PrototypeSet |
sumar(PrototypeSet other)
SUMAR dos conjuntos de prototipos , uno a uno.
|
double |
sumOfWeights() |
void |
swap(int i1,
int i2)
Swaps two elements of the prototype set.
|
PrototypeSet |
testCV(int numFolds,
int numFold)
Creates the test set for one fold of a cross-validation on
the dataset.
|
java.lang.String[][] |
to8GrayString()
Transform the prototypeSet (this) in a matrix of binary string Gray Code
|
java.lang.String[][] |
toBinaryString()
Transform the prototypeSet (this) in a matrix of binary string 8-bit codification.
|
java.util.HashMap<Prototype,java.lang.Integer> |
toHashMap()
Converts the dataset into a hashmap (Prototype p, index of p in the set)
|
java.util.HashSet<Prototype> |
toHashSet()
Converts the dataset into a hashset ¿Para qué cojones se usa?
|
InstanceSet |
toInstanceSet()
Transform the prototype set to a instance set object.
|
void |
toPrototypeSet(java.lang.String[][] datos,
double[] clases)
Transform a matrix of binary string 8-bit codification in a double PrototypeSEt
|
java.lang.String |
toString()
Converts data set into a String.
|
PrototypeSet |
trainCV(int numFolds,
int numFold)
Creates the training set for one fold of a cross-validation
on the dataset.
|
PrototypeSet |
union(PrototypeSet other)
Join two prototype sets
|
boolean |
uniqueAdd(Prototype newProt)
Adds prototype only if it is not already in the set.
|
static double |
variance(PrototypeSet ps,
Prototype center)
Returns variance of prototype set to the center.
|
PrototypeSet |
without(Prototype other)
Returns a copy of the set without an prototype.
|
PrototypeSet |
without(PrototypeSet other)
Returns a copy of the set without an element.
|
add, add, addAll, addAll, clear, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
public static InstanceSet associatedInstanceSet
protected static java.util.ArrayList<java.lang.Integer> FeaturesSet1
protected static java.util.ArrayList<java.lang.Integer> FeaturesSet2
public PrototypeSet()
public PrototypeSet(int numberOfElements)
numberOfElements
- Maximum inicial capacity.public PrototypeSet(InstanceSet s)
s
- InstanceSet used to build the implicit parameter.public PrototypeSet(PrototypeSet source, int first, int toCopy)
source
- the set of instances from which a subset
is to be createdfirst
- the index of the first instance to be copiedtoCopy
- the number of instances to be copiedpublic PrototypeSet(java.util.ArrayList<PrototypeSet> parts)
parts
- Partition of other prototype set.public PrototypeSet(PrototypeSet original)
original
- Original set to be copied.public int compareTo(java.lang.Object o1)
compareTo
in interface java.lang.Comparable
public InstanceSet toInstanceSet()
public PrototypeSet isTheNearPrototype(Prototype other)
public PrototypeSet isTheNearPrototypeWithClass(Prototype other, double clase)
public Prototype nearestTo(PrototypeSet current)
current
- public Prototype nearestTo(Prototype current)
current
- Prototype which the algorithm will find its nearest-neighbor.public Prototype containing(Prototype current)
current.
- public int IndexNearestTo(Prototype current)
current
- Prototype which the algorithm will find its nearest-neighbor.public int IndexSecondNearestTo(Prototype current)
current
- Prototype which the algorithm will find its nearest-neighbor.public Pair<Prototype,java.lang.Double> minimumLengthAndNearestTo(Prototype current)
current
- Prototype which the algorithm will find its nearest-neighbor.public Pair<Prototype,java.lang.Double> minimumLengthAndNearestWithSameClassAs(Prototype current)
current
- Prototype which the algorithm will find its nearest-neighbor.public Pair<Prototype,Prototype> nearestPair()
public Prototype nearestToWithClass(Prototype current, double label)
current
- Prototype which the algorithm will find its nearest-neighbor.label
- Class that must have this nearest to current.public Prototype nearestToWithDifferentClass(Prototype current, double label)
current
- Prototype which the algorithm will find its nearest-neighbor.label
- Class that must have this nearest to current.public boolean uniqueAdd(Prototype newProt)
newProt
- New prototype to be added to the set.public Prototype farthestTo(Prototype current)
current
- Prototype which the algorithm will find its farthest-neighbor.public Prototype getRandom()
public Prototype removeRandom()
public PrototypeSet getFromClass(double _class)
_class
- Choosen class .public PrototypeSet getAllDifferentFromClass(double _class)
_class
- Choosen class .public boolean containsSeveralClasses()
public java.util.HashMap<java.lang.Double,java.lang.Integer> countPrototypesOfEachOutput()
public java.util.HashMap<java.lang.Double,java.lang.Integer> getFrequencyOfClasses()
public java.util.ArrayList<java.lang.Double> nonVoidClasses()
public java.util.ArrayList<java.lang.Double> classesWithPrototypes()
public double mostFrequentClass()
public java.lang.String toString()
toString
in class java.util.AbstractCollection<Prototype>
public void print()
public PrototypeSet clone()
clone
in class java.util.ArrayList<Prototype>
public PrototypeSet copy()
public java.util.HashSet<Prototype> toHashSet()
public java.util.HashMap<Prototype,java.lang.Integer> toHashMap()
public PrototypeSet sort(Prototype current)
current
- Prototype base to be compared to every element of the set.public Pair<Prototype,Prototype> farthestPrototypes()
public Pair<PrototypeSet,PrototypeSet> partIntoSubsetsWhichSeedPointsAre(Prototype p1, Prototype p2)
p1
- Prototype whose closer prototypes will be in first set.p2
- Prototype whose closer prototypes will be in second set.public Pair<PrototypeSet,PrototypeSet> partIntoSubsetsWhichSeedPointsAre(Pair<Prototype,Prototype> pair)
pair
- Pair of prototypes which will determine the partition.public double Overlapping()
public boolean homogeneity()
public Pair<PrototypeSet,PrototypeSet> partIntoSubsetsOverlappingDegree(Prototype p1, Prototype p2)
p1
- Prototype whose closer prototypes will be in first set.p2
- Prototype whose closer prototypes will be in second set.public Pair<PrototypeSet,PrototypeSet> partIntoSubsetsOverlappingDegree(Pair<Prototype,Prototype> pair)
pair
- Pair of prototypes which will determine the partition.public java.util.ArrayList<PrototypeSet> classPartition()
public void swap(int i1, int i2)
i1
- First element.i2
- Second element.public void randomize()
PrototypeGenerator
public void randomize(long shuffleSeed)
shuffleSeed
- Seed of the random generator.public Pair<PrototypeSet,PrototypeSet> makePartitionPerClass(double percentInFirst)
percentInFirst
- Percentile of the prototyepes that willbe in the first set.public Pair<PrototypeSet,PrototypeSet> makePartition(double percentInFirst)
percentInFirst
- Percentile of the prototyepes that willbe in the first set.public java.util.ArrayList<PrototypeSet> partIn(int numberOfSets)
numberOfSets
- Number of subsets of the prototype set to be generated.public double largestDiameter()
public java.lang.String asKeelDataFileString(java.lang.String title)
title
- Title of the data set (required for all keel data files)public java.lang.String asKeelDataFileString()
public void save(java.lang.String filename)
filename
- Name of the output file.public PrototypeSet union(PrototypeSet other)
other
- Set to unite.public PrototypeSet join(Prototype other)
other
- Other prototype to be joined.public PrototypeSet without(PrototypeSet other)
other
- Element to be removed of the returned copy.public Prototype borrar(int index)
public boolean remove(Prototype other)
public boolean remove(PrototypeSet other)
public boolean removeWithoutClass(Prototype other)
public boolean removeWithoutClass(PrototypeSet other)
other
- public boolean pertenece(Prototype other)
public boolean perteneceSinClass(Prototype other)
public PrototypeSet without(Prototype other)
other
- Element to be removed of the returned copy.public PrototypeSet minus(PrototypeSet other)
other
- Element to be removed of the returned copy.public Prototype avg()
public Prototype sd()
public void add(PrototypeSet other)
other
- Set with the elements to include.public void addNoRepetition(PrototypeSet other)
other
- Set with the elements to include.public void addPrototype(Prototype other)
one
- prototypepublic void addPrototypeNoRepetition(Prototype other)
public PrototypeSet addPrototype2(Prototype other)
other
- public java.util.ArrayList<java.lang.Double> getPosibleValuesOfOutput()
Prototype.possibleValuesOfOutput()
public Pair<Prototype,java.lang.Double> radius(Prototype center)
center
- Prototype to be euclidean-distance compared.public Pair<Prototype,java.lang.Double> antiRadius(Prototype center)
center
- Prototype to be euclidean-distance compared.public double maxDistanceTo(Prototype center)
center
- Prototype to be euclidean-distance compared.public double minDistanceTo(Prototype center)
center
- Prototype to be euclidean-distance compared.public double minDist(Prototype uno)
public static double variance(PrototypeSet ps, Prototype center)
ps
- Prototype set to be measured.center
- Average prototype.public void applyThresholds()
public void printSet()
public double[][] prototypeSetTodouble()
public int[] prototypeSetClasses()
public void doubleToprototypeSet(double[][] datos, int clase)
public PrototypeSet sumar(PrototypeSet other)
public PrototypeSet restar(PrototypeSet other)
public PrototypeSet mulEscalar(double escalar)
public PrototypeSet opposite()
public java.lang.String[][] toBinaryString()
public java.lang.String[][] to8GrayString()
public void toPrototypeSet(java.lang.String[][] datos, double[] clases)
public void formatear(PrototypeSet initial)
public PrototypeSet getFeatures(java.util.ArrayList<java.lang.Integer> lista)
lista
- public java.util.ArrayList<java.lang.Integer> quicksort(java.util.ArrayList<java.lang.Integer> numbers)
numbers
- public java.util.ArrayList<java.lang.Integer> getFeatures1()
public java.util.ArrayList<java.lang.Integer> getFeatures2()
public Pair<PrototypeSet,PrototypeSet> divideFeaturesRandomly()
public PrototypeSet[] divideFeaturesRandomly(int subspaces, int dimension, int[][] indices)
subspaces
- dimension
- should be the half of the number of features!public PrototypeSet[] divideFeaturesRandomly(int[][] indices)
indices
- public PrototypeSet resample()
public double sumOfWeights()
protected void stratStep(int numFolds)
numFolds
- the number of folds for the stratificationpublic void stratify(int numFolds)
numFolds
- the number of folds in the cross-validationpublic PrototypeSet trainCV(int numFolds, int numFold)
numFolds
- the number of folds in the cross-validation. Must
be greater than 1.numFold
- 0 for the first fold, 1 for the second, ...public PrototypeSet testCV(int numFolds, int numFold)
numFolds
- the number of folds in the cross-validation. Must
be greater than 1.numFold
- 0 for the first fold, 1 for the second, ...public void sort(int attIndex)
attIndex
- the attribute's index (index starts with 0)protected int partition(int attIndex, int l, int r)
attIndex
- the attribute's index (index starts with 0)l
- the first index of the subset (index starts with 0)r
- the last index of the subset (index starts with 0)protected void quickSort(int attIndex, int left, int right)
attIndex
- the attribute's index (index starts with 0)left
- the first index of the subset to be sorted (index starts with 0)right
- the last index of the subset to be sorted (index starts with 0)