code
stringlengths 11
173k
| docstring
stringlengths 2
593k
| func_name
stringlengths 2
189
| language
stringclasses 1
value | repo
stringclasses 833
values | path
stringlengths 11
294
| url
stringlengths 60
339
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public ROCBinary(int thresholdSteps, boolean rocRemoveRedundantPts) {
this.thresholdSteps = thresholdSteps;
this.rocRemoveRedundantPts = rocRemoveRedundantPts;
} |
@param thresholdSteps Number of threshold steps to use for the ROC calculation. If set to 0: use exact calculation
@param rocRemoveRedundantPts Usually set to true. If true, remove any redundant points from ROC and P-R curves
| private::ROCBinary | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public int numLabels() {
if (underlying == null) {
return -1;
}
return underlying.length;
} |
Returns the number of labels - (i.e., size of the prediction/labels arrays) - if known. Returns -1 otherwise
| private::numLabels | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public long getCountActualPositive(int outputNum) {
assertIndex(outputNum);
return underlying[outputNum].getCountActualPositive();
} |
Get the actual positive count (accounting for any masking) for the specified output/column
@param outputNum Index of the output (0 to {@link #numLabels()}-1)
| private::getCountActualPositive | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public long getCountActualNegative(int outputNum) {
assertIndex(outputNum);
return underlying[outputNum].getCountActualNegative();
} |
Get the actual negative count (accounting for any masking) for the specified output/column
@param outputNum Index of the output (0 to {@link #numLabels()}-1)
| private::getCountActualNegative | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public ROC getROC(int outputNum){
assertIndex(outputNum);
return underlying[outputNum];
} |
Get the ROC object for the specific column
@param outputNum Column (output number)
@return The underlying ROC object for this specific column
| private::getROC | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public RocCurve getRocCurve(int outputNum) {
assertIndex(outputNum);
return underlying[outputNum].getRocCurve();
} |
Get the ROC curve for the specified output
@param outputNum Number of the output to get the ROC curve for
@return ROC curve
| private::getRocCurve | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public PrecisionRecallCurve getPrecisionRecallCurve(int outputNum) {
assertIndex(outputNum);
return underlying[outputNum].getPrecisionRecallCurve();
} |
Get the Precision-Recall curve for the specified output
@param outputNum Number of the output to get the P-R curve for
@return Precision recall curve
| private::getPrecisionRecallCurve | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public double calculateAverageAuc() {
double ret = 0.0;
for (int i = 0; i < numLabels(); i++) {
ret += calculateAUC(i);
}
return ret / (double) numLabels();
} |
Macro-average AUC for all outcomes
@return the (macro-)average AUC for all outcomes.
| private::calculateAverageAuc | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public double calculateAverageAUCPR(){
double ret = 0.0;
for (int i = 0; i < numLabels(); i++) {
ret += calculateAUCPR(i);
}
return ret / (double) numLabels();
} |
@return the (macro-)average AUPRC (area under precision recall curve)
| private::calculateAverageAUCPR | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public double calculateAUC(int outputNum) {
assertIndex(outputNum);
return underlying[outputNum].calculateAUC();
} |
Calculate the AUC - Area Under (ROC) Curve<br>
Utilizes trapezoidal integration internally
@param outputNum Output number to calculate AUC for
@return AUC
| private::calculateAUC | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public double calculateAUCPR(int outputNum) {
assertIndex(outputNum);
return underlying[outputNum].calculateAUCPR();
} |
Calculate the AUCPR - Area Under Curve - Precision Recall<br>
Utilizes trapezoidal integration internally
@param outputNum Output number to calculate AUCPR for
@return AUCPR
| private::calculateAUCPR | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public void setLabelNames(List<String> labels) {
if (labels == null) {
this.labels = null;
return;
}
this.labels = new ArrayList<>(labels);
} |
Set the label names, for printing via {@link #stats()}
| private::setLabelNames | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCBinary.java | Apache-2.0 |
public RocCurve getRocCurve(int classIdx) {
assertIndex(classIdx);
return underlying[classIdx].getRocCurve();
} |
Get the (one vs. all) ROC curve for the specified class
@param classIdx Class index to get the ROC curve for
@return ROC curve for the given class
| private::getRocCurve | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | Apache-2.0 |
public PrecisionRecallCurve getPrecisionRecallCurve(int classIdx) {
assertIndex(classIdx);
return underlying[classIdx].getPrecisionRecallCurve();
} |
Get the (one vs. all) Precision-Recall curve for the specified class
@param classIdx Class to get the P-R curve for
@return Precision recall curve for the given class
| private::getPrecisionRecallCurve | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | Apache-2.0 |
public double calculateAUC(int classIdx) {
assertIndex(classIdx);
return underlying[classIdx].calculateAUC();
} |
Calculate the AUC - Area Under ROC Curve<br>
Utilizes trapezoidal integration internally
@return AUC
| private::calculateAUC | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | Apache-2.0 |
public double calculateAUCPR(int classIdx) {
assertIndex(classIdx);
return underlying[classIdx].calculateAUCPR();
} |
Calculate the AUPRC - Area Under Curve Precision Recall <br>
Utilizes trapezoidal integration internally
@return AUC
| private::calculateAUCPR | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | Apache-2.0 |
public double calculateAverageAUC() {
assertIndex(0);
double sum = 0.0;
for (int i = 0; i < underlying.length; i++) {
sum += calculateAUC(i);
}
return sum / underlying.length;
} |
Calculate the macro-average (one-vs-all) AUC for all classes
| private::calculateAverageAUC | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | Apache-2.0 |
public double calculateAverageAUCPR() {
double sum = 0.0;
for (int i = 0; i < underlying.length; i++) {
sum += calculateAUCPR(i);
}
return sum / underlying.length;
} |
Calculate the macro-average (one-vs-all) AUCPR (area under precision recall curve) for all classes
| private::calculateAverageAUCPR | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROCMultiClass.java | Apache-2.0 |
public EvaluationBinary(INDArray decisionThreshold) {
if (decisionThreshold != null) {
if (!decisionThreshold.isRowVectorOrScalar()) {
throw new IllegalArgumentException(
"Decision threshold array must be a row vector; got array with shape "
+ Arrays.toString(decisionThreshold.shape()));
}
if (decisionThreshold.minNumber().doubleValue() < 0.0) {
throw new IllegalArgumentException("Invalid decision threshold array: minimum value is less than 0");
}
if (decisionThreshold.maxNumber().doubleValue() > 1.0) {
throw new IllegalArgumentException(
"invalid decision threshold array: maximum value is greater than 1.0");
}
this.decisionThreshold = decisionThreshold;
}
} |
Create an EvaulationBinary instance with an optional decision threshold array.
@param decisionThreshold Decision threshold for each output; may be null. Should be a row vector with length
equal to the number of outputs, with values in range 0 to 1. An array of 0.5 values is
equivalent to the default (no manually specified decision threshold).
| JsonDeserialize::EvaluationBinary | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public EvaluationBinary(int size, Integer rocBinarySteps) {
countTruePositive = new int[size];
countFalsePositive = new int[size];
countTrueNegative = new int[size];
countFalseNegative = new int[size];
if (rocBinarySteps != null) {
rocBinary = new ROCBinary(rocBinarySteps);
}
} |
This constructor allows for ROC to be calculated in addition to the standard evaluation metrics, when the
rocBinarySteps arg is non-null. See {@link ROCBinary} for more details
@param size Number of outputs
@param rocBinarySteps Constructor arg for {@link ROCBinary#ROCBinary(int)}
| JsonDeserialize::EvaluationBinary | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public int totalCount(int outputNum) {
assertIndex(outputNum);
return countTruePositive[outputNum] + countTrueNegative[outputNum] + countFalseNegative[outputNum]
+ countFalsePositive[outputNum];
} |
Get the total number of values for the specified column, accounting for any masking
| JsonDeserialize::totalCount | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public int truePositives(int outputNum) {
assertIndex(outputNum);
return countTruePositive[outputNum];
} |
Get the true positives count for the specified output
| JsonDeserialize::truePositives | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public int trueNegatives(int outputNum) {
assertIndex(outputNum);
return countTrueNegative[outputNum];
} |
Get the true negatives count for the specified output
| JsonDeserialize::trueNegatives | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public int falsePositives(int outputNum) {
assertIndex(outputNum);
return countFalsePositive[outputNum];
} |
Get the false positives count for the specified output
| JsonDeserialize::falsePositives | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public int falseNegatives(int outputNum) {
assertIndex(outputNum);
return countFalseNegative[outputNum];
} |
Get the false negatives count for the specified output
| JsonDeserialize::falseNegatives | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double accuracy(int outputNum) {
assertIndex(outputNum);
return (countTruePositive[outputNum] + countTrueNegative[outputNum]) / (double) totalCount(outputNum);
} |
Get the accuracy for the specified output
| JsonDeserialize::accuracy | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double precision(int outputNum) {
assertIndex(outputNum);
//double precision = tp / (double) (tp + fp);
return countTruePositive[outputNum] / (double) (countTruePositive[outputNum] + countFalsePositive[outputNum]);
} |
Get the precision (tp / (tp + fp)) for the specified output
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double recall(int outputNum) {
assertIndex(outputNum);
return countTruePositive[outputNum] / (double) (countTruePositive[outputNum] + countFalseNegative[outputNum]);
} |
Get the recall (tp / (tp + fn)) for the specified output
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double fBeta(double beta, int outputNum) {
assertIndex(outputNum);
double precision = precision(outputNum);
double recall = recall(outputNum);
return EvaluationUtils.fBeta(beta, precision, recall);
} |
Calculate the F-beta value for the given output
@param beta Beta value to use
@param outputNum Output number
@return F-beta for the given output
| JsonDeserialize::fBeta | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double f1(int outputNum) {
return fBeta(1.0, outputNum);
} |
Get the F1 score for the specified output
| JsonDeserialize::f1 | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double matthewsCorrelation(int outputNum) {
assertIndex(outputNum);
return EvaluationUtils.matthewsCorrelation(truePositives(outputNum), falsePositives(outputNum),
falseNegatives(outputNum), trueNegatives(outputNum));
} |
Calculate the Matthews correlation coefficient for the specified output
@param outputNum Output number
@return Matthews correlation coefficient
| JsonDeserialize::matthewsCorrelation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double averageMatthewsCorrelation() {
double ret = 0.0;
for (int i = 0; i < numLabels(); i++) {
ret += matthewsCorrelation(i);
}
ret /= (double) numLabels();
return ret;
} |
Macro average of the Matthews correlation coefficient (MCC) (see {@link #matthewsCorrelation(int)}) for all labels.
@return The macro average of the MCC for all labels.
| JsonDeserialize::averageMatthewsCorrelation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double gMeasure(int output) {
double precision = precision(output);
double recall = recall(output);
return EvaluationUtils.gMeasure(precision, recall);
} |
Calculate the macro average G-measure for the given output
@param output The specified output
@return The macro average of the G-measure for the specified output
| JsonDeserialize::gMeasure | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double averageGMeasure() {
double ret = 0.0;
for (int i = 0; i < numLabels(); i++) {
ret += gMeasure(i);
}
ret /= (double) numLabels();
return ret;
} |
Average G-measure (see {@link #gMeasure(int)}) for all labels.
@return The G-measure for all labels.
| JsonDeserialize::averageGMeasure | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double falsePositiveRate(int classLabel) {
assertIndex(classLabel);
return falsePositiveRate(classLabel, DEFAULT_EDGE_VALUE);
} |
Returns the false positive rate for a given label
@param classLabel the label
@return fpr as a double
| JsonDeserialize::falsePositiveRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double falsePositiveRate(int classLabel, double edgeCase) {
double fpCount = falsePositives(classLabel);
double tnCount = trueNegatives(classLabel);
return EvaluationUtils.falsePositiveRate((long) fpCount, (long) tnCount, edgeCase);
} |
Returns the false positive rate for a given label
@param classLabel the label
@param edgeCase What to output in case of 0/0
@return fpr as a double
| JsonDeserialize::falsePositiveRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double falseNegativeRate(Integer classLabel) {
return falseNegativeRate(classLabel, DEFAULT_EDGE_VALUE);
} |
Returns the false negative rate for a given label
@param classLabel the label
@return fnr as a double
| JsonDeserialize::falseNegativeRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double falseNegativeRate(Integer classLabel, double edgeCase) {
double fnCount = falseNegatives(classLabel);
double tpCount = truePositives(classLabel);
return EvaluationUtils.falseNegativeRate((long) fnCount, (long) tpCount, edgeCase);
} |
Returns the false negative rate for a given label
@param classLabel the label
@param edgeCase What to output in case of 0/0
@return fnr as a double
| JsonDeserialize::falseNegativeRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public ROCBinary getROCBinary() {
return rocBinary;
} |
Returns the {@link ROCBinary} instance, if present
| JsonDeserialize::getROCBinary | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double averageFalseAlarmRate() {
double ret = 0.0;
for (int i = 0; i < numLabels(); i++) {
ret += falseAlarmRate(i);
}
ret /= (double) numLabels();
return ret;
} |
Average False Alarm Rate (FAR) (see {@link #falseAlarmRate(int)}) for all labels.
@return The FAR for all labels.
| JsonDeserialize::averageFalseAlarmRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double falseAlarmRate(int outputNum) {
assertIndex(outputNum);
return (falsePositiveRate(outputNum) + falseNegativeRate(outputNum)) / 2.0;
} |
False Alarm Rate (FAR) reflects rate of misclassified to classified records
<a href="http://ro.ecu.edu.au/cgi/viewcontent.cgi?article=1058&context=isw">http://ro.ecu.edu.au/cgi/viewcontent.cgi?article=1058&context=isw</a><br>
@param outputNum Class index to calculate False Alarm Rate (FAR)
@return The FAR for the outcomes
| JsonDeserialize::falseAlarmRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public String stats() {
return stats(DEFAULT_PRECISION);
} |
Get a String representation of the EvaluationBinary class, using the default precision
| JsonDeserialize::stats | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public String stats(int printPrecision) {
StringBuilder sb = new StringBuilder();
//Report: Accuracy, precision, recall, F1. Then: confusion matrix
int maxLabelsLength = 15;
if (labels != null) {
for (String s : labels) {
maxLabelsLength = Math.max(s.length(), maxLabelsLength);
}
}
String subPattern = "%-12." + printPrecision + "f";
String pattern = "%-" + (maxLabelsLength + 5) + "s" //Label
+ subPattern + subPattern + subPattern + subPattern //Accuracy, f1, precision, recall
+ "%-8d%-7d%-7d%-7d%-7d"; //Total count, TP, TN, FP, FN
String patternHeader = "%-" + (maxLabelsLength + 5) + "s%-12s%-12s%-12s%-12s%-8s%-7s%-7s%-7s%-7s";
List<String> headerNames = Arrays.asList("Label", "Accuracy", "F1", "Precision", "Recall", "Total", "TP", "TN",
"FP", "FN");
if (rocBinary != null) {
patternHeader += "%-12s";
pattern += subPattern;
headerNames = new ArrayList<>(headerNames);
headerNames.add("AUC");
}
String header = String.format(patternHeader, headerNames.toArray());
sb.append(header);
if (countTrueNegative != null) {
for (int i = 0; i < countTrueNegative.length; i++) {
int totalCount = totalCount(i);
double acc = accuracy(i);
double f1 = f1(i);
double precision = precision(i);
double recall = recall(i);
String label = (labels == null ? String.valueOf(i) : labels.get(i));
List<Object> args = Arrays.<Object>asList(label, acc, f1, precision, recall, totalCount,
truePositives(i), trueNegatives(i), falsePositives(i), falseNegatives(i));
if (rocBinary != null) {
args = new ArrayList<>(args);
args.add(rocBinary.calculateAUC(i));
}
sb.append("\n").append(String.format(pattern, args.toArray()));
}
if (decisionThreshold != null) {
sb.append("\nPer-output decision thresholds: ")
.append(Arrays.toString(decisionThreshold.dup().data().asFloat()));
}
} else {
//Empty evaluation
sb.append("\n-- No Data --\n");
}
return sb.toString();
} |
Get a String representation of the EvaluationBinary class, using the specified precision
@param printPrecision The precision (number of decimal places) for the accuracy, f1, etc.
| JsonDeserialize::stats | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public double scoreForMetric(Metric metric, int outputNum){
switch (metric){
case ACCURACY:
return accuracy(outputNum);
case F1:
return f1(outputNum);
case PRECISION:
return precision(outputNum);
case RECALL:
return recall(outputNum);
case GMEASURE:
return gMeasure(outputNum);
case MCC:
return matthewsCorrelation(outputNum);
case FAR:
return falseAlarmRate(outputNum);
default:
throw new IllegalStateException("Unknown metric: " + metric);
}
} |
Calculate specific metric (see {@link Metric}) for a given label.
@param metric The Metric to calculate.
@param outputNum Class index to calculate.
@return Calculated metric.
| JsonDeserialize::scoreForMetric | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationBinary.java | Apache-2.0 |
public ConfusionMatrix(List<T> classes) {
this.matrix = new ConcurrentHashMap<>();
this.classes = classes;
} |
Creates an empty confusion Matrix
| ConfusionMatrix::ConfusionMatrix | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public ConfusionMatrix(ConfusionMatrix<T> other) {
this(other.getClasses());
this.add(other);
} |
Creates a new ConfusionMatrix initialized with the contents of another ConfusionMatrix.
| ConfusionMatrix::ConfusionMatrix | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public synchronized void add(T actual, T predicted) {
add(actual, predicted, 1);
} |
Increments the entry specified by actual and predicted by one.
| ConfusionMatrix::add | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public synchronized void add(T actual, T predicted, int count) {
if (matrix.containsKey(actual)) {
matrix.get(actual).add(predicted, count);
} else {
Multiset<T> counts = HashMultiset.create();
counts.add(predicted, count);
matrix.put(actual, counts);
}
} |
Increments the entry specified by actual and predicted by count.
| ConfusionMatrix::add | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public synchronized void add(ConfusionMatrix<T> other) {
for (T actual : other.matrix.keySet()) {
Multiset<T> counts = other.matrix.get(actual);
for (T predicted : counts.elementSet()) {
int count = counts.count(predicted);
this.add(actual, predicted, count);
}
}
} |
Adds the entries from another confusion matrix to this one.
| ConfusionMatrix::add | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public List<T> getClasses() {
if (classes == null)
classes = new ArrayList<>();
return classes;
} |
Gives the applyTransformToDestination of all classes in the confusion matrix.
| ConfusionMatrix::getClasses | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public synchronized int getCount(T actual, T predicted) {
if (!matrix.containsKey(actual)) {
return 0;
} else {
return matrix.get(actual).count(predicted);
}
} |
Gives the count of the number of times the "predicted" class was predicted for the "actual"
class.
| ConfusionMatrix::getCount | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public synchronized int getPredictedTotal(T predicted) {
int total = 0;
for (T actual : classes) {
total += getCount(actual, predicted);
}
return total;
} |
Computes the total number of times the class was predicted by the classifier.
| ConfusionMatrix::getPredictedTotal | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public synchronized int getActualTotal(T actual) {
if (!matrix.containsKey(actual)) {
return 0;
} else {
int total = 0;
for (T elem : matrix.get(actual).elementSet()) {
total += matrix.get(actual).count(elem);
}
return total;
}
} |
Computes the total number of times the class actually appeared in the data.
| ConfusionMatrix::getActualTotal | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public String toCSV() {
StringBuilder builder = new StringBuilder();
// Header Row
builder.append(",,Predicted Class,\n");
// Predicted Classes Header Row
builder.append(",,");
for (T predicted : classes) {
builder.append(String.format("%s,", predicted));
}
builder.append("Total\n");
// Data Rows
String firstColumnLabel = "Actual Class,";
for (T actual : classes) {
builder.append(firstColumnLabel);
firstColumnLabel = ",";
builder.append(String.format("%s,", actual));
for (T predicted : classes) {
builder.append(getCount(actual, predicted));
builder.append(",");
}
// Actual Class Totals Column
builder.append(getActualTotal(actual));
builder.append("\n");
}
// Predicted Class Totals Row
builder.append(",Total,");
for (T predicted : classes) {
builder.append(getPredictedTotal(predicted));
builder.append(",");
}
builder.append("\n");
return builder.toString();
} |
Outputs the ConfusionMatrix as comma-separated values for easy import into spreadsheets
| ConfusionMatrix::toCSV | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public String toHTML() {
StringBuilder builder = new StringBuilder();
int numClasses = classes.size();
// Header Row
builder.append("<table>\n");
builder.append("<tr><th class=\"empty-space\" colspan=\"2\" rowspan=\"2\">");
builder.append(String.format("<th class=\"predicted-class-header\" colspan=\"%d\">Predicted Class</th></tr>%n",
numClasses + 1));
// Predicted Classes Header Row
builder.append("<tr>");
// builder.append("<th></th><th></th>");
for (T predicted : classes) {
builder.append("<th class=\"predicted-class-header\">");
builder.append(predicted);
builder.append("</th>");
}
builder.append("<th class=\"predicted-class-header\">Total</th>");
builder.append("</tr>\n");
// Data Rows
String firstColumnLabel = String.format(
"<tr><th class=\"actual-class-header\" rowspan=\"%d\">Actual Class</th>", numClasses + 1);
for (T actual : classes) {
builder.append(firstColumnLabel);
firstColumnLabel = "<tr>";
builder.append(String.format("<th class=\"actual-class-header\" >%s</th>", actual));
for (T predicted : classes) {
builder.append("<td class=\"count-element\">");
builder.append(getCount(actual, predicted));
builder.append("</td>");
}
// Actual Class Totals Column
builder.append("<td class=\"count-element\">");
builder.append(getActualTotal(actual));
builder.append("</td>");
builder.append("</tr>\n");
}
// Predicted Class Totals Row
builder.append("<tr><th class=\"actual-class-header\">Total</th>");
for (T predicted : classes) {
builder.append("<td class=\"count-element\">");
builder.append(getPredictedTotal(predicted));
builder.append("</td>");
}
builder.append("<td class=\"empty-space\"></td>\n");
builder.append("</tr>\n");
builder.append("</table>\n");
return builder.toString();
} |
Outputs Confusion Matrix in an HTML table. Cascading Style Sheets (CSS) can control the table's
appearance by defining the empty-space, actual-count-header, predicted-class-header, and
count-element classes. For example
@return html string
| ConfusionMatrix::toHTML | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ConfusionMatrix.java | Apache-2.0 |
public ROC(int thresholdSteps) {
this(thresholdSteps, true);
} |
@param thresholdSteps Number of threshold steps to use for the ROC calculation. If set to 0: use exact calculation
| Metric::ROC | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROC.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROC.java | Apache-2.0 |
public ROC(int thresholdSteps, boolean rocRemoveRedundantPts) {
this(thresholdSteps, rocRemoveRedundantPts, DEFAULT_EXACT_ALLOC_BLOCK_SIZE);
} |
@param thresholdSteps Number of threshold steps to use for the ROC calculation. If set to 0: use exact calculation
@param rocRemoveRedundantPts Usually set to true. If true, remove any redundant points from ROC and P-R curves
| Metric::ROC | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROC.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROC.java | Apache-2.0 |
public ROC(int thresholdSteps, boolean rocRemoveRedundantPts, int exactAllocBlockSize) {
if (thresholdSteps > 0) {
this.thresholdSteps = thresholdSteps;
double step = 1.0 / thresholdSteps;
for (int i = 0; i <= thresholdSteps; i++) {
double currThreshold = i * step;
counts.put(currThreshold, new CountsForThreshold(currThreshold));
}
isExact = false;
} else {
//Exact
isExact = true;
}
this.rocRemoveRedundantPts = rocRemoveRedundantPts;
this.exactAllocBlockSize = exactAllocBlockSize;
} |
@param thresholdSteps Number of threshold steps to use for the ROC calculation. If set to 0: use exact calculation
@param rocRemoveRedundantPts Usually set to true. If true, remove any redundant points from ROC and P-R curves
@param exactAllocBlockSize if using exact mode, the block size relocation. Users can likely use the default
setting in almost all cases
| Metric::ROC | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROC.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/ROC.java | Apache-2.0 |
public Evaluation(int numClasses) {
this(numClasses, (numClasses == 2 ? 1 : null));
} |
The number of classes to account for in the evaluation
@param numClasses the number of classes to account for in the evaluation
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(int numClasses, Integer binaryPositiveClass){
this(createLabels(numClasses), 1);
if(binaryPositiveClass != null){
Preconditions.checkArgument(binaryPositiveClass == 0 || binaryPositiveClass == 1,
"Only 0 and 1 are valid inputs for binaryPositiveClass; got " + binaryPositiveClass);
Preconditions.checkArgument(numClasses == 2, "Cannot set binaryPositiveClass argument " +
"when number of classes is not equal to 2 (got: numClasses=" + numClasses + ")");
}
this.binaryPositiveClass = binaryPositiveClass;
} |
Constructor for specifying the number of classes, and optionally the positive class for binary classification.
See Evaluation javadoc for more details on evaluation in the binary case
@param numClasses The number of classes for the evaluation. Must be 2, if binaryPositiveClass is non-null
@param binaryPositiveClass If non-null, the positive class (0 or 1).
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(List<String> labels) {
this(labels, 1);
} |
The labels to include with the evaluation.
This constructor can be used for
generating labeled output rather than just
numbers for the labels
@param labels the labels to use
for the output
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(Map<Integer, String> labels) {
this(createLabelsFromMap(labels), 1);
} |
Use a map to generate labels
Pass in a label index with the actual label
you want to use for output
@param labels a map of label index to label value
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(List<String> labels, int topN) {
this.labelsList = labels;
if (labels != null) {
createConfusion(labels.size());
}
this.topN = topN;
if(labels != null && labels.size() == 2){
this.binaryPositiveClass = 1;
}
} |
Constructor to use for top N accuracy
@param labels Labels for the classes (may be null)
@param topN Value to use for top N accuracy calculation (<=1: standard accuracy). Note that with top N
accuracy, an example is considered 'correct' if the probability for the true class is one of the
highest N values
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(double binaryDecisionThreshold) {
this(binaryDecisionThreshold, 1);
} |
Create an evaluation instance with a custom binary decision threshold. Note that binary decision thresholds can
only be used with binary classifiers.<br>
Defaults to class 1 for the positive class - see class javadoc, and use {@link #Evaluation(double, Integer)} to
change this.
@param binaryDecisionThreshold Decision threshold to use for binary predictions
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(double binaryDecisionThreshold, @NonNull Integer binaryPositiveClass) {
if(binaryPositiveClass != null){
Preconditions.checkArgument(binaryPositiveClass == 0 || binaryPositiveClass == 1,
"Only 0 and 1 are valid inputs for binaryPositiveClass; got " + binaryPositiveClass);
}
this.binaryDecisionThreshold = binaryDecisionThreshold;
this.topN = 1;
this.binaryPositiveClass = binaryPositiveClass;
} |
Create an evaluation instance with a custom binary decision threshold. Note that binary decision thresholds can
only be used with binary classifiers.<br>
This constructor also allows the user to specify the positive class for binary classification. See class javadoc
for more details.
@param binaryDecisionThreshold Decision threshold to use for binary predictions
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(INDArray costArray) {
this(null, costArray);
} |
Created evaluation instance with the specified cost array. A cost array can be used to bias the multi class
predictions towards or away from certain classes. The predicted class is determined using argMax(cost * probability)
instead of argMax(probability) when no cost array is present.
@param costArray Row vector cost array. May be null
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public Evaluation(List<String> labels, INDArray costArray) {
if (costArray != null && !costArray.isRowVectorOrScalar()) {
throw new IllegalArgumentException("Invalid cost array: must be a row vector (got shape: "
+ Arrays.toString(costArray.shape()) + ")");
}
if (costArray != null && costArray.minNumber().doubleValue() < 0.0) {
throw new IllegalArgumentException("Invalid cost array: Cost array values must be positive");
}
this.labelsList = labels;
this.costArray = costArray == null ? null : costArray.castTo(DataType.FLOAT);
this.topN = 1;
} |
Created evaluation instance with the specified cost array. A cost array can be used to bias the multi class
predictions towards or away from certain classes. The predicted class is determined using argMax(cost * probability)
instead of argMax(probability) when no cost array is present.
@param labels Labels for the output classes. May be null
@param costArray Row vector cost array. May be null
| JsonDeserialize::Evaluation | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public void eval(INDArray realOutcomes, INDArray guesses) {
eval(realOutcomes, guesses, (List<Serializable>) null);
} |
Collects statistics on the real outcomes vs the
guesses. This is for logistic outcome matrices.
<p>
Note that an IllegalArgumentException is thrown if the two passed in
matrices aren't the same length.
@param realOutcomes the real outcomes (labels - usually binary)
@param guesses the guesses/prediction (usually a probability vector)
| JsonDeserialize::eval | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public void eval(int predictedIdx, int actualIdx) {
// Add the number of rows to numRowCounter
numRowCounter++;
// If confusion is null, then Evaluation is instantiated without providing the classes
if (confusion == null) {
throw new UnsupportedOperationException(
"Cannot evaluate single example without initializing confusion matrix first");
}
addToConfusion(actualIdx, predictedIdx);
// If they are equal
if (predictedIdx == actualIdx) {
// Then add 1 to True Positive
// (For a particular label)
incrementTruePositives(predictedIdx);
// And add 1 for each negative class that is accurately predicted (True Negative)
//(For a particular label)
for (Integer clazz : confusion().getClasses()) {
if (clazz != predictedIdx)
trueNegatives.incrementCount(clazz, 1.0f);
}
} else {
// Otherwise the real label is predicted as negative (False Negative)
incrementFalseNegatives(actualIdx);
// Otherwise the prediction is predicted as falsely positive (False Positive)
incrementFalsePositives(predictedIdx);
// Otherwise true negatives
for (Integer clazz : confusion().getClasses()) {
if (clazz != predictedIdx && clazz != actualIdx)
trueNegatives.incrementCount(clazz, 1.0f);
}
}
} |
Evaluate a single prediction (one prediction at a time)
@param predictedIdx Index of class predicted by the network
@param actualIdx Index of actual class
| JsonDeserialize::eval | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String stats() {
return stats(false);
} |
Report the classification statistics as a String
@return Classification statistics as a String
| JsonDeserialize::stats | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String stats(boolean suppressWarnings) {
return stats(suppressWarnings, numClasses() <= CONFUSION_PRINT_MAX_CLASSES, numClasses() > CONFUSION_PRINT_MAX_CLASSES);
} |
Method to obtain the classification report as a String
@param suppressWarnings whether or not to output warnings related to the evaluation results
@return A (multi-line) String with accuracy, precision, recall, f1 score etc
| JsonDeserialize::stats | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String stats(boolean suppressWarnings, boolean includeConfusion){
return stats(suppressWarnings, includeConfusion, false);
} |
Method to obtain the classification report as a String
@param suppressWarnings whether or not to output warnings related to the evaluation results
@param includeConfusion whether the confusion matrix should be included it the returned stats or not
@return A (multi-line) String with accuracy, precision, recall, f1 score etc
| JsonDeserialize::stats | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public String confusionMatrix(){
int nClasses = numClasses();
if(confusion == null){
return "Confusion matrix: <no data>";
}
//First: work out the maximum count
List<Integer> classes = confusion.getClasses();
int maxCount = 1;
for (Integer i : classes) {
for (Integer j : classes) {
int count = confusion().getCount(i, j);
maxCount = Math.max(maxCount, count);
}
}
maxCount = Math.max(maxCount, nClasses); //Include this as header might be bigger than actual values
int numDigits = (int)Math.ceil(Math.log10(maxCount));
if(numDigits < 1)
numDigits = 1;
String digitFormat = "%" + (numDigits+1) + "d";
StringBuilder sb = new StringBuilder();
//Build header:
for( int i=0; i<nClasses; i++ ){
sb.append(String.format(digitFormat, i));
}
sb.append("\n");
int numDividerChars = (numDigits+1) * nClasses + 1;
for( int i=0; i<numDividerChars; i++ ){
sb.append("-");
}
sb.append("\n");
//Build each row:
for( int actual=0; actual<nClasses; actual++){
String actualName = resolveLabelForClass(actual);
for( int predicted=0; predicted<nClasses; predicted++){
int count = confusion.getCount(actual, predicted);
sb.append(String.format(digitFormat, count));
}
sb.append(" | ").append(actual).append(" = ").append(actualName).append("\n");
}
sb.append("\nConfusion matrix format: Actual (rowClass) predicted as (columnClass) N times");
return sb.toString();
} |
Get the confusion matrix as a String
@return Confusion matrix as a String
| JsonDeserialize::confusionMatrix | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double precision(Integer classLabel) {
return precision(classLabel, DEFAULT_EDGE_VALUE);
} |
Returns the precision for a given class label
@param classLabel the label
@return the precision for the label
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double precision(Integer classLabel, double edgeCase) {
Preconditions.checkState(numRowCounter > 0, "Cannot get precision: no evaluation has been performed");
double tpCount = truePositives.getCount(classLabel);
double fpCount = falsePositives.getCount(classLabel);
return EvaluationUtils.precision((long) tpCount, (long) fpCount, edgeCase);
} |
Returns the precision for a given label
@param classLabel the label
@param edgeCase What to output in case of 0/0
@return the precision for the label
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double precision() {
if(binaryPositiveClass != null && numClasses() == 2){
return precision(binaryPositiveClass);
}
return precision(EvaluationAveraging.Macro);
} |
Precision based on guesses so far.<br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged precision, equivalent to {@code precision(EvaluationAveraging.Macro)}<br>
@return the total precision based on guesses so far
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double precision(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get precision: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroPrecision = 0.0;
int count = 0;
for (int i = 0; i < nClasses; i++) {
double thisClassPrec = precision(i, -1);
if (thisClassPrec != -1) {
macroPrecision += thisClassPrec;
count++;
}
}
macroPrecision /= count;
return macroPrecision;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fpCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fpCount += falsePositives.getCount(i);
}
return EvaluationUtils.precision(tpCount, fpCount, DEFAULT_EDGE_VALUE);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average precision for all classes. Can specify whether macro or micro averaging should be used
NOTE: if any classes have tp=0 and fp=0, (precision=0/0) these are excluded from the average
@param averaging Averaging method - macro or micro
@return Average precision
| JsonDeserialize::precision | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int averagePrecisionNumClassesExcluded() {
return numClassesExcluded("precision");
} |
When calculating the (macro) average precision, how many classes are excluded from the average due to
no predictions - i.e., precision would be the edge case of 0/0
@return Number of classes excluded from the average precision
| JsonDeserialize::averagePrecisionNumClassesExcluded | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int averageRecallNumClassesExcluded() {
return numClassesExcluded("recall");
} |
When calculating the (macro) average Recall, how many classes are excluded from the average due to
no predictions - i.e., recall would be the edge case of 0/0
@return Number of classes excluded from the average recall
| JsonDeserialize::averageRecallNumClassesExcluded | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int averageF1NumClassesExcluded() {
return numClassesExcluded("f1");
} |
When calculating the (macro) average F1, how many classes are excluded from the average due to
no predictions - i.e., F1 would be calculated from a precision or recall of 0/0
@return Number of classes excluded from the average F1
| JsonDeserialize::averageF1NumClassesExcluded | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public int averageFBetaNumClassesExcluded() {
return numClassesExcluded("fbeta");
} |
When calculating the (macro) average FBeta, how many classes are excluded from the average due to
no predictions - i.e., FBeta would be calculated from a precision or recall of 0/0
@return Number of classes excluded from the average FBeta
| JsonDeserialize::averageFBetaNumClassesExcluded | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double recall(int classLabel) {
return recall(classLabel, DEFAULT_EDGE_VALUE);
} |
Returns the recall for a given label
@param classLabel the label
@return Recall rate as a double
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double recall(int classLabel, double edgeCase) {
Preconditions.checkState(numRowCounter > 0, "Cannot get recall: no evaluation has been performed");
double tpCount = truePositives.getCount(classLabel);
double fnCount = falseNegatives.getCount(classLabel);
return EvaluationUtils.recall((long) tpCount, (long) fnCount, edgeCase);
} |
Returns the recall for a given label
@param classLabel the label
@param edgeCase What to output in case of 0/0
@return Recall rate as a double
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double recall() {
if(binaryPositiveClass != null && numClasses() == 2){
return recall(binaryPositiveClass);
}
return recall(EvaluationAveraging.Macro);
} |
Recall based on guesses so far<br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged recall, equivalent to {@code recall(EvaluationAveraging.Macro)}<br>
@return the recall for the outcomes
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double recall(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get recall: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroRecall = 0.0;
int count = 0;
for (int i = 0; i < nClasses; i++) {
double thisClassRecall = recall(i, -1);
if (thisClassRecall != -1) {
macroRecall += thisClassRecall;
count++;
}
}
macroRecall /= count;
return macroRecall;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fnCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fnCount += falseNegatives.getCount(i);
}
return EvaluationUtils.recall(tpCount, fnCount, DEFAULT_EDGE_VALUE);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average recall for all classes - can specify whether macro or micro averaging should be used
NOTE: if any classes have tp=0 and fn=0, (recall=0/0) these are excluded from the average
@param averaging Averaging method - macro or micro
@return Average recall
| JsonDeserialize::recall | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falsePositiveRate() {
if(binaryPositiveClass != null && numClasses() == 2){
return falsePositiveRate(binaryPositiveClass);
}
return falsePositiveRate(EvaluationAveraging.Macro);
} |
False positive rate based on guesses so far<br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged false positive rate, equivalent to
{@code falsePositiveRate(EvaluationAveraging.Macro)}<br>
@return the fpr for the outcomes
| JsonDeserialize::falsePositiveRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falsePositiveRate(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get false positive rate: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroFPR = 0.0;
for (int i = 0; i < nClasses; i++) {
macroFPR += falsePositiveRate(i);
}
macroFPR /= nClasses;
return macroFPR;
} else if (averaging == EvaluationAveraging.Micro) {
long fpCount = 0;
long tnCount = 0;
for (int i = 0; i < nClasses; i++) {
fpCount += falsePositives.getCount(i);
tnCount += trueNegatives.getCount(i);
}
return EvaluationUtils.falsePositiveRate(fpCount, tnCount, DEFAULT_EDGE_VALUE);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average false positive rate across all classes. Can specify whether macro or micro averaging should be used
@param averaging Averaging method - macro or micro
@return Average false positive rate
| JsonDeserialize::falsePositiveRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falseNegativeRate() {
if(binaryPositiveClass != null && numClasses() == 2){
return falseNegativeRate(binaryPositiveClass);
}
return falseNegativeRate(EvaluationAveraging.Macro);
} |
False negative rate based on guesses so far
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged false negative rate, equivalent to
{@code falseNegativeRate(EvaluationAveraging.Macro)}<br>
@return the fnr for the outcomes
| JsonDeserialize::falseNegativeRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falseNegativeRate(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get false negative rate: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroFNR = 0.0;
for (int i = 0; i < nClasses; i++) {
macroFNR += falseNegativeRate(i);
}
macroFNR /= nClasses;
return macroFNR;
} else if (averaging == EvaluationAveraging.Micro) {
long fnCount = 0;
long tnCount = 0;
for (int i = 0; i < nClasses; i++) {
fnCount += falseNegatives.getCount(i);
tnCount += trueNegatives.getCount(i);
}
return EvaluationUtils.falseNegativeRate(fnCount, tnCount, DEFAULT_EDGE_VALUE);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average false negative rate for all classes - can specify whether macro or micro averaging should be used
@param averaging Averaging method - macro or micro
@return Average false negative rate
| JsonDeserialize::falseNegativeRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double falseAlarmRate() {
if(binaryPositiveClass != null && numClasses() == 2){
return (falsePositiveRate(binaryPositiveClass) + falseNegativeRate(binaryPositiveClass)) / 2.0;
}
return (falsePositiveRate() + falseNegativeRate()) / 2.0;
} |
False Alarm Rate (FAR) reflects rate of misclassified to classified records
<a href="http://ro.ecu.edu.au/cgi/viewcontent.cgi?article=1058&context=isw">http://ro.ecu.edu.au/cgi/viewcontent.cgi?article=1058&context=isw</a><br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged false alarm rate)
@return the fpr for the outcomes
| JsonDeserialize::falseAlarmRate | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double f1(int classLabel) {
return fBeta(1.0, classLabel);
} |
Calculate f1 score for a given class
@param classLabel the label to calculate f1 for
@return the f1 score for the given label
| JsonDeserialize::f1 | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double fBeta(double beta, int classLabel) {
return fBeta(beta, classLabel, 0.0);
} |
Calculate the f_beta for a given class, where f_beta is defined as:<br>
(1+beta^2) * (precision * recall) / (beta^2 * precision + recall).<br>
F1 is a special case of f_beta, with beta=1.0
@param beta Beta value to use
@param classLabel Class label
@return F_beta
| JsonDeserialize::fBeta | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double fBeta(double beta, int classLabel, double defaultValue) {
Preconditions.checkState(numRowCounter > 0, "Cannot get fBeta score: no evaluation has been performed");
double precision = precision(classLabel, -1);
double recall = recall(classLabel, -1);
if (precision == -1 || recall == -1) {
return defaultValue;
}
return EvaluationUtils.fBeta(beta, precision, recall);
} |
Calculate the f_beta for a given class, where f_beta is defined as:<br>
(1+beta^2) * (precision * recall) / (beta^2 * precision + recall).<br>
F1 is a special case of f_beta, with beta=1.0
@param beta Beta value to use
@param classLabel Class label
@param defaultValue Default value to use when precision or recall is undefined (0/0 for prec. or recall)
@return F_beta
| JsonDeserialize::fBeta | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double f1() {
if(binaryPositiveClass != null && numClasses() == 2){
return f1(binaryPositiveClass);
}
return f1(EvaluationAveraging.Macro);
} |
Calculate the F1 score<br>
F1 score is defined as:<br>
TP: true positive<br>
FP: False Positive<br>
FN: False Negative<br>
F1 score: 2 * TP / (2TP + FP + FN)<br>
<br>
Note: value returned will differ depending on number of classes and settings.<br>
1. For binary classification, if the positive class is set (via default value of 1, via constructor,
or via {@link #setBinaryPositiveClass(Integer)}), the returned value will be for the specified positive class
only.<br>
2. For the multi-class case, or when {@link #getBinaryPositiveClass()} is null, the returned value is macro-averaged
across all classes. i.e., is macro-averaged f1, equivalent to {@code f1(EvaluationAveraging.Macro)}<br>
@return the f1 score or harmonic mean of precision and recall based on current guesses
| JsonDeserialize::f1 | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double f1(EvaluationAveraging averaging) {
return fBeta(1.0, averaging);
} |
Calculate the average F1 score across all classes, using macro or micro averaging
@param averaging Averaging method to use
| JsonDeserialize::f1 | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double fBeta(double beta, EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get fBeta score: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (nClasses == 2) {
return EvaluationUtils.fBeta(beta, (long) truePositives.getCount(1), (long) falsePositives.getCount(1),
(long) falseNegatives.getCount(1));
}
if (averaging == EvaluationAveraging.Macro) {
double macroFBeta = 0.0;
int count = 0;
for (int i = 0; i < nClasses; i++) {
double thisFBeta = fBeta(beta, i, -1);
if (thisFBeta != -1) {
macroFBeta += thisFBeta;
count++;
}
}
macroFBeta /= count;
return macroFBeta;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fpCount = 0;
long fnCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fpCount += falsePositives.getCount(i);
fnCount += falseNegatives.getCount(i);
}
return EvaluationUtils.fBeta(beta, tpCount, fpCount, fnCount);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculate the average F_beta score across all classes, using macro or micro averaging
@param beta Beta value to use
@param averaging Averaging method to use
| JsonDeserialize::fBeta | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double gMeasure(int output) {
Preconditions.checkState(numRowCounter > 0, "Cannot get gMeasure: no evaluation has been performed");
double precision = precision(output);
double recall = recall(output);
return EvaluationUtils.gMeasure(precision, recall);
} |
Calculate the G-measure for the given output
@param output The specified output
@return The G-measure for the specified output
| JsonDeserialize::gMeasure | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double gMeasure(EvaluationAveraging averaging) {
Preconditions.checkState(numRowCounter > 0, "Cannot get gMeasure: no evaluation has been performed");
int nClasses = confusion().getClasses().size();
if (averaging == EvaluationAveraging.Macro) {
double macroGMeasure = 0.0;
for (int i = 0; i < nClasses; i++) {
macroGMeasure += gMeasure(i);
}
macroGMeasure /= nClasses;
return macroGMeasure;
} else if (averaging == EvaluationAveraging.Micro) {
long tpCount = 0;
long fpCount = 0;
long fnCount = 0;
for (int i = 0; i < nClasses; i++) {
tpCount += truePositives.getCount(i);
fpCount += falsePositives.getCount(i);
fnCount += falseNegatives.getCount(i);
}
double precision = EvaluationUtils.precision(tpCount, fpCount, DEFAULT_EDGE_VALUE);
double recall = EvaluationUtils.recall(tpCount, fnCount, DEFAULT_EDGE_VALUE);
return EvaluationUtils.gMeasure(precision, recall);
} else {
throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
}
} |
Calculates the average G measure for all outputs using micro or macro averaging
@param averaging Averaging method to use
@return Average G measure
| JsonDeserialize::gMeasure | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double accuracy() {
Preconditions.checkState(numRowCounter > 0, "Cannot get accuracy: no evaluation has been performed");
//Accuracy: sum the counts on the diagonal of the confusion matrix, divide by total
int nClasses = confusion().getClasses().size();
int countCorrect = 0;
for (int i = 0; i < nClasses; i++) {
countCorrect += confusion().getCount(i, i);
}
return countCorrect / (double) getNumRowCounter();
} |
Accuracy:
(TP + TN) / (P + N)
@return the accuracy of the guesses so far
| JsonDeserialize::accuracy | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
public double topNAccuracy() {
if (topN <= 1)
return accuracy();
if (topNTotalCount == 0)
return 0.0;
return topNCorrectCount / (double) topNTotalCount;
} |
Top N accuracy of the predictions so far. For top N = 1 (default), equivalent to {@link #accuracy()}
@return Top N accuracy
| JsonDeserialize::topNAccuracy | java | deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | https://github.com/deeplearning4j/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.