<commit_before>package tudarmstadt.lt.ABSentiment.featureExtractor.util;


import java.util.ArrayList;
import java.util.HashMap;

/**
 * A java Class for Confusion Matrix and Error Analysis
 */
public class ConfusionMatrix {

    ArrayList<String> labels = new ArrayList<>();
    HashMap<Pair<String, String>, Integer> matrix = new HashMap<>();

    public void addLabel(String label){
        labels.add(label);
    }

    public void createMatrix(){
        for(String predictedLabel:labels){
            for(String goldLabel:labels){
                matrix.put(new Pair<>(predictedLabel, goldLabel), 0);
            }
        }
    }

    /**
     * Adds an entry to the confusion matrix
     * @param predictedLabel the predicted label for the instance
     * @param goldLabel the actual gold label for the instance
     */
    public void updateMatrix(String predictedLabel, String goldLabel){
        matrix.put(new Pair<>(predictedLabel, goldLabel), matrix.get(new Pair<>(predictedLabel, goldLabel))+1);
    }

    /**
     * Prints the confusion matrix
     */
    public void printConfusionMatrix(){
        System.out.println("Gold labels      : Left to Right");
        System.out.println("Predicted labels : Top to bottom");
        for(String label:labels){
            System.out.print("\t"+label);
        }
        for(String predictedLabel:labels){
            System.out.print("\n"+predictedLabel);
            for(String goldLabel:labels){
                System.out.print("\t"+matrix.get(new Pair<>(predictedLabel, goldLabel)));<commit_msg>updated the printing style of confusion matrix<commit_after>package tudarmstadt.lt.ABSentiment.featureExtractor.util;


import java.util.ArrayList;
import java.util.HashMap;

/**
 * A java Class for Confusion Matrix and Error Analysis
 */
public class ConfusionMatrix {

    ArrayList<String> labels = new ArrayList<>();
    HashMap<Pair<String, String>, Integer> matrix = new HashMap<>();

    public void addLabel(String label){
        labels.add(label);
    }

    public void createMatrix(){
        for(String predictedLabel:labels){
            for(String goldLabel:labels){
                matrix.put(new Pair<>(predictedLabel, goldLabel), 0);
            }
        }
    }

    /**
     * Adds an entry to the confusion matrix
     * @param predictedLabel the predicted label for the instance
     * @param goldLabel the actual gold label for the instance
     */
    public void updateMatrix(String predictedLabel, String goldLabel){
        matrix.put(new Pair<>(predictedLabel, goldLabel), matrix.get(new Pair<>(predictedLabel, goldLabel))+1);
    }

    /**
     * Prints the confusion matrix
     */
    public void printConfusionMatrix(){
        System.out.println("\nGold labels      : Left to Right");
        System.out.println("Predicted labels : Top to bottom");
        for(String label:labels){
            System.out.print("\t"+label);
        }
        for(String predictedLabel:labels){
            System.out.print("\n"+predictedLabel);
            for(String goldLabel:labels){
                System.out.print("\t"+matrix.get(new Pair<>(predictedLabel, goldLabel)));
{'fraction_non_alphanumeric': 0.1144215530903328, 'fraction_numerical': 0.0012678288431061807, 'mean_word_length': 2.77511961722488, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6038332', 'n_tokens_mistral': 838, 'n_tokens_neox': 823, 'n_words': 221}