public class Heuristics extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Heuristics.HeuristicType |
Constructor and Description |
---|
Heuristics() |
Modifier and Type | Method and Description |
---|---|
static double |
divideOrZero(int numerator,
int denominator) |
static double |
getAScore(double recall,
double precision)
Computes arithmetic mean of precision and recall, which is called "A-Score"
here (A=arithmetic), but is not an established notion in machine learning.
|
static double |
getAScore(double recall,
double precision,
double beta)
Computes arithmetic mean of precision and recall, which is called "A-Score"
here (A=arithmetic), but is not an established notion in machine learning.
|
static double[] |
getAScoreApproximationStep1(double beta,
int nrOfPosExamples,
int nrOfInstanceChecks,
int nrOfSuccessfulInstanceChecks)
In the first step of the AScore approximation, we estimate recall (taking the factor
beta into account).
|
static double[] |
getAScoreApproximationStep2(int nrOfPosClassifiedPositives,
double[] recallInterval,
double beta,
int nrOfRelevantInstances,
int nrOfInstanceChecks,
int nrOfSuccessfulInstanceChecks)
In step 2 of the A-Score approximation, the precision and overall A-Score is estimated based on
the estimated recall.
|
static double[] |
getConfidenceInterval95Wald(int total,
int success)
Computes the 95% confidence interval of an experiment with boolean outcomes,
e.g.
|
static double |
getConfidenceInterval95WaldAverage(int total,
int success)
Computes the 95% confidence interval average of an experiment with boolean outcomes,
e.g.
|
static double |
getFScore(double recall,
double precision)
Computes F1-Score.
|
static double |
getFScore(double recall,
double precision,
double beta)
Computes F-beta-Score.
|
static double[] |
getFScoreApproximation(int nrOfPosClassifiedPositives,
double recall,
double beta,
int nrOfRelevantInstances,
int nrOfInstanceChecks,
int nrOfSuccessfulInstanceChecks)
This method can be used to approximate F-Measure and thereby saving a lot of
instance checks.
|
static double |
getFScoreBalanced(double recall,
double precision,
double beta) |
static double |
getJaccardCoefficient(int elementsIntersection,
int elementsUnion)
Computes the Jaccard coefficient of two sets.
|
static double |
getMatthewsCorrelationCoefficient(int tp,
int fp,
int tn,
int fn) |
static double[] |
getPredAccApproximation(int nrOfPositiveExamples,
int nrOfNegativeExamples,
double beta,
int nrOfPosExampleInstanceChecks,
int nrOfSuccessfulPosExampleChecks,
int nrOfNegExampleInstanceChecks,
int nrOfNegativeNegExampleChecks) |
static double |
getPredictiveAccuracy(int nrOfExamples,
int nrOfPosClassifiedPositives,
int nrOfNegClassifiedNegatives) |
static double |
getPredictiveAccuracy(int nrOfPosExamples,
int nrOfNegExamples,
int nrOfPosClassifiedPositives,
int nrOfNegClassifiedNegatives,
double beta) |
static double |
getPredictiveAccuracy2(int nrOfExamples,
int nrOfPosClassifiedPositives,
int nrOfPosClassifiedNegatives) |
static double |
getPredictiveAccuracy2(int nrOfPosExamples,
int nrOfNegExamples,
int nrOfPosClassifiedPositives,
int nrOfNegClassifiedNegatives,
double beta) |
boolean |
isTooWeak(int nrOfPositiveExamples,
int nrOfPosClassifiedPositives,
double noise)
Computes whether a hypothesis is too weak, i.e.
|
boolean |
isTooWeak2(int nrOfPositiveExamples,
int nrOfNegClassifiedPositives,
double noise)
Computes whether a hypothesis is too weak, i.e.
|
static double |
p1(int success,
int total) |
static double |
p3(double p1,
int total) |
public Heuristics()
public static double getFScore(double recall, double precision)
recall
- Recall.precision
- Precision.public static double getFScore(double recall, double precision, double beta)
recall
- Recall.precision
- Precision.beta
- Weights precision and recall. If beta is >1, then recall is more important
than precision.public static double getFScoreBalanced(double recall, double precision, double beta)
public static double getAScore(double recall, double precision)
recall
- Recall.precision
- Precison.public static double getAScore(double recall, double precision, double beta)
recall
- Recall.precision
- Precison.beta
- Weights precision and recall. If beta is >1, then recall is more important
than precision.public static double getJaccardCoefficient(int elementsIntersection, int elementsUnion)
elementsIntersection
- Number of elements in the intersection of the two sets.elementsUnion
- Number of elements in the union of the two sets.public static double getPredictiveAccuracy(int nrOfExamples, int nrOfPosClassifiedPositives, int nrOfNegClassifiedNegatives)
public static double getPredictiveAccuracy(int nrOfPosExamples, int nrOfNegExamples, int nrOfPosClassifiedPositives, int nrOfNegClassifiedNegatives, double beta)
public static double getPredictiveAccuracy2(int nrOfExamples, int nrOfPosClassifiedPositives, int nrOfPosClassifiedNegatives)
public static double getPredictiveAccuracy2(int nrOfPosExamples, int nrOfNegExamples, int nrOfPosClassifiedPositives, int nrOfNegClassifiedNegatives, double beta)
public static double getMatthewsCorrelationCoefficient(int tp, int fp, int tn, int fn)
public static double[] getConfidenceInterval95Wald(int total, int success)
success
- Number of successes, e.g. number of times the coin shows head.total
- Total number of tries, e.g. total number of times the coin was thrown.public static double getConfidenceInterval95WaldAverage(int total, int success)
success
- Number of successes, e.g. number of times the coin shows head.total
- Total number of tries, e.g. total number of times the coin was thrown.public boolean isTooWeak(int nrOfPositiveExamples, int nrOfPosClassifiedPositives, double noise)
nrOfPositiveExamples
- The number of positive examples in the learning problem.nrOfPosClassifiedPositives
- The number of positive examples, which were indeed classified as positive by the hypothesis.noise
- The noise parameter is a value between 0 and 1, which indicates how noisy the example data is (0 = no noise, 1 = completely random).
If a hypothesis contains more errors on the positive examples than the noise value multiplied by the
number of all examples, then the hypothesis is too weak.public boolean isTooWeak2(int nrOfPositiveExamples, int nrOfNegClassifiedPositives, double noise)
nrOfPositiveExamples
- The number of positive examples in the learning problem.nrOfNegClassifiedPositives
- The number of positive examples, which were indeed classified as negative by the hypothesis.noise
- The noise parameter is a value between 0 and 1, which indicates how noisy the example data is (0 = no noise, 1 = completely random).
If a hypothesis contains more errors on the positive examples than the noise value multiplied by the
number of all examples, then the hypothesis is too weak.public static double p1(int success, int total)
public static double p3(double p1, int total)
public static double[] getFScoreApproximation(int nrOfPosClassifiedPositives, double recall, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks)
nrOfPosClassifiedPositives
- Positive examples (instance of a class), which are classified as positives.recall
- The already known recall.beta
- Weights precision and recall. If beta is >1, then recall is more important
than precision.nrOfRelevantInstances
- Number of relevant instances, i.e. number of instances, which
would have been tested without approximations. TODO: relevant = pos + neg examples?nrOfInstanceChecks
- Performed instance checks for the approximation.nrOfSuccessfulInstanceChecks
- Number of successful performed instance checks.public static double[] getAScoreApproximationStep1(double beta, int nrOfPosExamples, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks)
beta
- Weights precision and recall. If beta is >1, then recall is more important
than precision.nrOfPosExamples
- Number of positive examples (or instances of the considered class).nrOfInstanceChecks
- Number of positive examples (or instances of the considered class) which have been checked.nrOfSuccessfulInstanceChecks
- Number of positive examples (or instances of the considered class), where the instance check returned true.public static double[] getAScoreApproximationStep2(int nrOfPosClassifiedPositives, double[] recallInterval, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks)
nrOfPosClassifiedPositives
- Positive examples (instance of a class), which are classified as positives.recallInterval
- The estimated recall, which needs to be given as a two element array with the first element being the mean value and the second element being the length of the interval (to be compatible with the step1 method).beta
- Weights precision and recall. If beta is >1, then recall is more important
than precision.nrOfRelevantInstances
- Number of relevant instances, i.e. number of instances, which
would have been tested without approximations.nrOfInstanceChecks
- Performed instance checks for the approximation.nrOfSuccessfulInstanceChecks
- Number of performed instance checks, which returned true.public static double[] getPredAccApproximation(int nrOfPositiveExamples, int nrOfNegativeExamples, double beta, int nrOfPosExampleInstanceChecks, int nrOfSuccessfulPosExampleChecks, int nrOfNegExampleInstanceChecks, int nrOfNegativeNegExampleChecks)
public static double divideOrZero(int numerator, int denominator)
DL-Learner is licenced under the terms of the GNU General Public License.
Copyright © 2007-2019 Jens Lehmann