deeplearning4j-core/src/main/java/org/deeplearning4j/eval/Evaluation.java
/** Method to obtain the classification report, as a String
     * @return A (multi-line) String with accuracy, precision, recall, f1 score etc
     */
Method to obtain the classification report, as a String
@return A (multi-line) String with accuracy, precision, recall, f1 score etc
Method to obtain the classification report as a String @return A ( multi - line ) String with accuracy precision recall f1 score etc
public String stats() {
        StringBuilder builder = new StringBuilder().append("\n");
        String actual, expected;
        List<Integer> classes = confusion.getClasses();
        if (labelsMap.isEmpty()){
            for (Integer clazz : classes) {
                for (Integer clazz2 : classes) {
                    int count = confusion.getCount(clazz, clazz2);
                    if (count != 0)
                        builder.append("\n Examples labeled as " + clazz + " classified by model as " + clazz2 + ": " + count + " times\n");
                }
            }
        } else {
            for (Integer clazz : classes) {
                for (Integer clazz2 : classes) {
                    int count = confusion.getCount(clazz, clazz2);
                    if (count != 0 && !labelsMap.get(clazz2).isEmpty()) {
                        actual = labelsMap.get(clazz).isEmpty() ? clazz.toString() : labelsMap.get(clazz);
                        expected = labelsMap.get(clazz2).isEmpty() ? clazz2.toString() : labelsMap.get(clazz2);
                        builder.append("\n Examples labeled as " + actual + " classified by model as " + expected + ": " + count + " times\n");
                    }
                }
            }
        }
        DecimalFormat df = new DecimalFormat("#.####");
        builder.append("\n==========================Scores========================================");
        builder.append("\n Accuracy:  " + df.format(accuracy()));
        builder.append("\n Precision: " + df.format(precision()));
        builder.append("\n Recall:    " + df.format(recall()));
        builder.append("\n F1 Score:  " + f1());
        builder.append("\n===========================================================================");
        return builder.toString();
    }
public String stats ( ) { StringBuilder builder = new StringBuilder ( ) . append ( "\n" ) ; String actual , expected ; List < Integer > classes = confusion . getClasses ( ) ; if ( labelsMap . isEmpty ( ) ) { for ( Integer clazz : classes ) { for ( Integer clazz2 : classes ) { int count = confusion . getCount ( clazz , clazz2 ) ; if ( count != 0 ) builder . append ( "\n Examples labeled as " + clazz + " classified by model as " + clazz2 + ": " + count + " times\n" ) ; } } } else { for ( Integer clazz : classes ) { for ( Integer clazz2 : classes ) { int count = confusion . getCount ( clazz , clazz2 ) ; if ( count != 0 && ! labelsMap . get ( clazz2 ) . isEmpty ( ) ) { actual = labelsMap . get ( clazz ) . isEmpty ( ) ? clazz . toString ( ) : labelsMap . get ( clazz ) ; expected = labelsMap . get ( clazz2 ) . isEmpty ( ) ? clazz2 . toString ( ) : labelsMap . get ( clazz2 ) ; builder . append ( "\n Examples labeled as " + actual + " classified by model as " + expected + ": " + count + " times\n" ) ; } } } } DecimalFormat df = new DecimalFormat ( "#.####" ) ; builder . append ( "\n==========================Scores========================================" ) ; builder . append ( "\n Accuracy:  " + df . format ( accuracy ( ) ) ) ; builder . append ( "\n Precision: " + df . format ( precision ( ) ) ) ; builder . append ( "\n Recall:    " + df . format ( recall ( ) ) ) ; builder . append ( "\n F1 Score:  " + f1 ( ) ) ; builder . append ( "\n===========================================================================" ) ; return builder . toString ( ) ; }
Method to obtain the classification report, as a String
 @return A (multi-line) String with accuracy, precision, recall, f1 score etc
Method to obtain the classification report as a String @return A ( multi - line ) String with accuracy precision recall f1 score etc