public class PrototypeSet extends java.util.ArrayList<Prototype> implements java.lang.Comparable
Modifier and Type | Field and Description |
---|---|
protected InstanceSet |
associatedInstanceSet
Associated instance set to the prototype set.
|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
add(PrototypeSet other)
Add the elements of a set.
|
void |
addPrototype(Prototype other)
Add one prototype to the set..
|
PrototypeSet |
addPrototype2(Prototype other)
this + 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.
|
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[] |
Cmeans(double[][] datosTrain,
int C,
double[][] centers)
Executes the k means algorithm.
|
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.
|
void |
doubleToprototypeSet(double[][] datos,
int clase)
PrototypeSet from double values.
|
void |
doubleToprototypeSet(double[][] datos,
int[] clase)
PrototypeSet from double values.
|
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)
Adds the elements of a reset set given.
|
PrototypeSet |
getAllDifferentFromClass(double _class)
Select all the patterns of different classs.
|
int[] |
getClases()
Returns the classes, as a vector of integers, of all the prototypes included in this set.
|
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 prototypes in (this) that has "other" as the nearest neighbour
|
PrototypeSet |
isTheNearPrototypeWithClass(Prototype other,
double clase)
Return all the prototypes in (this) that has "other" as the nearest neighbour 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)
Returns 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)
Multiply the set by a number given.
|
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 |
nearestToWithClass(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()
Computes inverse set, element by element. (1 - value)
|
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.
|
boolean |
pertenece(Prototype other)
Checks the existence of the prototype given as argument in this set.
|
void |
print()
Prints the prototype in the terminal
|
void |
printSet()
Print Prototype Set.
|
double[][] |
prototypeSetTodouble()
PrototypeSet to double.
|
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)
Removes a prototype given as parameter from the set.
|
Prototype |
removeRandom()
Remove a random prototype (and returns it)
|
PrototypeSet |
restar(PrototypeSet other)
Subtracts two prototype sets, element by element.
|
void |
save(java.lang.String filename)
Save the data in a file (Keel style)
|
Prototype |
sd()
Performs standard desviation operation of the prototype set.
|
static PrototypeSet |
selecRandomSet(PrototypeSet original,
int numberOfPrototypesSelected,
boolean usePriorProb)
Returns a random subset of the given one as parameter with the size given.
|
PrototypeSet |
sort(Prototype current)
Sort the prototype set in ascending distance to current prototype.
|
PrototypeSet |
sumar(PrototypeSet other)
Sums two prototype sets, element by element.
|
void |
swap(int i1,
int i2)
Swaps two elements of the prototype set.
|
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?
|
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 |
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
protected InstanceSet associatedInstanceSet
public PrototypeSet()
public PrototypeSet(int numberOfElements)
numberOfElements
- Maximum inicial capacity.public PrototypeSet(InstanceSet s)
s
- InstanceSet used to build the implicit parameter.public 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 PrototypeSet isTheNearPrototype(Prototype other)
other
- element to be considered as the nearest neighbour.public PrototypeSet isTheNearPrototypeWithClass(Prototype other, double clase)
other
- element to be considered as the nearest neighbour.clase
- given class to check.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 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 boolean remove(Prototype other)
other
- prototype to remove from this set.public boolean pertenece(Prototype other)
other
- the prototype to check.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 addPrototype(Prototype other)
other
- one prototypepublic 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)
uno
- prototype given to compute the distance with.public static double variance(PrototypeSet ps, Prototype center)
ps
- Prototype set to be measured.center
- Average prototype.public void applyThresholds()
public void printSet()
public int[] Cmeans(double[][] datosTrain, int C, double[][] centers)
datosTrain
- training dataset.C
- number of clusters used.centers
- centers of the different clusterspublic void doubleToprototypeSet(double[][] datos, int[] clase)
datos
- input values of the data to include.clase
- output values of the data to include.public double[][] prototypeSetTodouble()
public int[] getClases()
public void doubleToprototypeSet(double[][] datos, int clase)
datos
- input values of the data to include.clase
- output values of the data to include.public PrototypeSet sumar(PrototypeSet other)
other
- the prototype to sum.public PrototypeSet restar(PrototypeSet other)
other
- the prototype to subtract.public PrototypeSet mulEscalar(double escalar)
escalar
- number to multiplypublic PrototypeSet opposite()
public java.lang.String[][] toBinaryString()
public java.lang.String[][] to8GrayString()
public void toPrototypeSet(java.lang.String[][] datos, double[] clases)
datos
- input values of the data to include.clases
- output values of the data to include.public void formatear(PrototypeSet initial)
initial
- given set.public static PrototypeSet selecRandomSet(PrototypeSet original, int numberOfPrototypesSelected, boolean usePriorProb)
original
- original set.numberOfPrototypesSelected
- number of prototypes to select from the original set.usePriorProb
- True if prior probabilities should be used, false otherwise.