001 package org.jaga.selection;
002
003
004 /**
005 * TODO: Complete these comments.
006 *
007 * <p><u>Project:</u> JAGA - Java API for Genetic Algorithms.</p>
008 *
009 * <p><u>Company:</u> University College London and JAGA.Org
010 * (<a href="http://www.jaga.org" target="_blank">http://www.jaga.org</a>).
011 * </p>
012 *
013 * <p><u>Copyright:</u> (c) 2004 by G. Paperin.<br/>
014 * This program is free software; you can redistribute it and/or modify
015 * it under the terms of the GNU General Public License as published by
016 * the Free Software Foundation, ONLY if you include a note of the original
017 * author(s) in any redistributed/modified copy.<br/>
018 * This program is distributed in the hope that it will be useful,
019 * but WITHOUT ANY WARRANTY; without even the implied warranty of
020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
021 * GNU General Public License for more details.<br/>
022 * You should have received a copy of the GNU General Public License
023 * along with this program; if not, write to the Free Software
024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
025 * or see http://www.gnu.org/licenses/gpl.html</p>
026 *
027 * @author Greg Paperin (greg@jaga.org)
028 *
029 * @version JAGA public release 1.0 beta
030 */
031
032 public class ClassifierFitness extends AbsoluteFitness {
033
034 private int truePositives = 0;
035 private int trueNegatives = 0;
036 private int falsePositives = 0;
037 private int falseNegatives = 0;
038 private double sensitivity = 0.;
039 private double specificity = 0.;
040
041 private ClassifierFitness() {
042 super(Double.NEGATIVE_INFINITY);
043 };
044
045 public ClassifierFitness(int truePositive, int trueNegative,
046 int falsePositive, int falseNegative,
047 double sensitivity, double specificity,
048 double fitnessValue) {
049 super(fitnessValue);
050 this.truePositives = truePositive;
051 this.trueNegatives = trueNegative;
052 this.falsePositives = falsePositive;
053 this.falseNegatives = falseNegative;
054 this.sensitivity = sensitivity;
055 this.specificity = specificity;
056 }
057
058 public String toString() {
059 StringBuffer s = new StringBuffer();
060 s.append(getValue());
061 s.append(" (TP=");
062 s.append(this.truePositives);
063 s.append(", TN=");
064 s.append(this.trueNegatives);
065 s.append(", FP=");
066 s.append(this.falsePositives);
067 s.append(", FN=");
068 s.append(this.falseNegatives);
069 s.append(", Sens=");
070 s.append(this.sensitivity);
071 s.append(", Spec=");
072 s.append(this.specificity);
073 s.append(", Quality=");
074 s.append(this.sensitivity + this.specificity);
075 s.append(")");
076 return s.toString();
077 }
078
079 public int getFalseNegatives() {
080 return falseNegatives;
081 }
082
083 public int getFalsePositives() {
084 return falsePositives;
085 }
086
087 public int getTrueNegatives() {
088 return trueNegatives;
089 }
090
091 public int getTruePositives() {
092 return truePositives;
093 }
094
095 /**
096 * in medical sence
097 */
098 public double getSensitivity() {
099 return sensitivity;
100 }
101
102 /**
103 * in medical sence
104 */
105 public double getSpecificity() {
106 return specificity;
107 }
108 }