001/** 002 * Copyright (C) 2007 - 2016, Jens Lehmann 003 * 004 * This file is part of DL-Learner. 005 * 006 * DL-Learner is free software; you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation; either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * DL-Learner is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package org.dllearner.learningproblems; 020 021import org.dllearner.core.Score; 022 023public class AxiomScore extends Score{ 024 025 private static final long serialVersionUID = 555252118489924570L; 026 private double accuracy; 027 private double confidence; 028 029 private int nrOfPositiveExamples = -1; 030 private int nrOfNegativeExamples = -1; 031 032 private boolean sampleBased; 033 034 public AxiomScore(double accuracy) { 035 this(accuracy, false); 036 } 037 038 public AxiomScore(double accuracy, boolean sampleBased) { 039 this.accuracy = accuracy; 040 this.sampleBased = sampleBased; 041 } 042 043 public AxiomScore(double accuracy, double confidence) { 044 this(accuracy, confidence, false); 045 } 046 047 public AxiomScore(double accuracy, double confidence, boolean sampleBased) { 048 this.accuracy = accuracy; 049 this.confidence = confidence; 050 this.sampleBased = sampleBased; 051 } 052 053 public AxiomScore(double accuracy, double confidence, int nrOfPositiveExamples, int nrOfNegativeExamples) { 054 this(accuracy, confidence, nrOfPositiveExamples, nrOfNegativeExamples, false); 055 } 056 057 public AxiomScore(double accuracy, double confidence, int nrOfPositiveExamples, int nrOfNegativeExamples, boolean sampleBased) { 058 this.accuracy = accuracy; 059 this.confidence = confidence; 060 this.nrOfPositiveExamples = nrOfPositiveExamples; 061 this.nrOfNegativeExamples = nrOfNegativeExamples; 062 this.sampleBased = sampleBased; 063 } 064 065 @Override 066 public double getAccuracy() { 067 return accuracy; 068 } 069 070 /** 071 * @return the confidence value. 072 */ 073 public double getConfidence(){ 074 return confidence; 075 } 076 077 /** 078 * @return whether the score was computed only based on a sample of the knowledge base 079 */ 080 public boolean isSampleBased() { 081 return sampleBased; 082 } 083 084 /** 085 * @return the total number of examples used to compute the score. 086 */ 087 public int getTotalNrOfExamples() { 088 return nrOfPositiveExamples + nrOfNegativeExamples; 089 } 090 091 /** 092 * @return the number of positive examples used to compute the score. 093 */ 094 public int getNrOfPositiveExamples() { 095 return nrOfPositiveExamples; 096 } 097 098 /** 099 * @return the number of negative examples used to compute the score. 100 */ 101 public int getNrOfNegativeExamples() { 102 return nrOfNegativeExamples; 103 } 104 105}