|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbodhidharma.classifiers.genetic_algorithms.Evaluator
bodhidharma.classifiers.genetic_algorithms.FeatureWeightingEvaluator
public class FeatureWeightingEvaluator
Objects of this class evaluate and interpret the meaning of bit strings stored in
genetic algorithm Chromosome
objects. Each bit in the bit string
represents part of the representation of a double. Each double represents the
weighting for a feature. This Evaluator
is used for finding a good
feature weighting.
The fitness value is calculated by performing a classification using a
KNN
classifier.
KNN
,
Chromosome
,
Breeder
Field Summary |
---|
Fields inherited from class bodhidharma.classifiers.genetic_algorithms.Evaluator |
---|
bit_string_length |
Constructor Summary | |
---|---|
FeatureWeightingEvaluator(KNN knn_classifier,
double[][] feature_values,
int[][] classifications,
int bits_per_value,
ClassificationResultsInterpereter results_interpereter)
Basic constructor. |
Method Summary | |
---|---|
double |
getFitness(short[] bit_string)
Return the fitness of a chromosome given its DNA (bit string). |
java.lang.Object[] |
parseBitString(short[] bit_string)
Returns an array of Doubles holding the meaning of the given bit string of a Chromosome . |
Methods inherited from class bodhidharma.classifiers.genetic_algorithms.Evaluator |
---|
getBitStringLength |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FeatureWeightingEvaluator(KNN knn_classifier, double[][] feature_values, int[][] classifications, int bits_per_value, ClassificationResultsInterpereter results_interpereter) throws java.lang.Exception
Throws an exception if the feature_values or classifications parameters are of improper sizes.
knn_classifier
- Trained KNN classifier used to evaluate the fitness of DNA.feature_values
- Test feature values that will be classified to test performance. First indice indicates recording and second indicates feature.classifications
- Model classifications of feature_values. First indice indicates recording. Entries indicate the indices of the categories that are correct classifications.bits_per_value
- Number of bits used to represent each weighting. More bits means a greater variety of possible values.results_interpereter
- Used to perform actual classifications so that fitnesses can be performed. Default fitness will be used if null.
java.lang.Exception
Method Detail |
---|
public double getFitness(short[] bit_string) throws java.lang.Exception
The fitness is calculated for each recording, and then averaged over all recordings.
There are two ways of calculating fitness. The first is used if the results_interpereter field is not null, and the second if it is null. The first way gives a fitness based on the fraction of correct classifications based on the given bit_string.
The alternative fitness for each recording is set equal to the sum of the normalized scores returned by the classifier for those categories to which the recording belongs.
If previous feature selection set a feature to not be used, its weighting
is interepereted as 0, irregardless of what it actually is, and its value is
changed to 0 in the bit string. This is done by parseBitString
method.
Throws an exception if there is a problem with the classification or if the length of the bit_string is not equal to the length of the bit_string_length field.
getFitness
in class Evaluator
java.lang.Exception
public java.lang.Object[] parseBitString(short[] bit_string) throws java.lang.Exception
Chromosome
. These values represent feature weightings
and fall between 0 and 1. If previous feature selection set a feature to not
be used, its weighting is interepereted as 0, irregardless of what it actually
is, and its value is changed to 0 in the bit string.
Throws an exception if the length of the bit_string is not equal to the length of the bit_string_length field or if it is not evenly divisible by the word length.
parseBitString
in class Evaluator
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |