|
|||||||||
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.FeatureSelectionEvaluator
public class FeatureSelectionEvaluator
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 the on (1) or off (0) setting of a feature. Features with an on
setting are used for classification and feautres with an off are not used in
classification. This Evaluator
is used for feature selection.
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 | |
---|---|
FeatureSelectionEvaluator(KNN knn_classifier,
double[][] feature_values,
int[][] classifications,
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 Booleans 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 FeatureSelectionEvaluator(KNN knn_classifier, double[][] feature_values, int[][] classifications, 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.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.
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
. Values of 1 in the given bit_string
are set to true and values of 0 are set to false. There is one element
in the returned array for each bit in the bit_string. Bit strings
passed to this method should be of the same length as the length specified
in the constructor of this object.
Throws an exception if the length of the bit_string is not equal to the length of the bit_string_length> field.
parseBitString
in class Evaluator
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |