using System;
using System.Collections.Generic;
using System.Linq;

namespace LabelerCore.Model
{
    public static class Scores
    {
        //Computes Confusion Matrix
        //1 dimension is true label, and 2 dimention is prediced label
        public static int[,] ConfusionMatrix(int[] yTrue, int[] yPred)
        {
            if (yTrue.Length != yPred.Length)
            {
                throw new
                ArgumentException("Input arrays have different length");
            }
            List<int> classes = yTrue.Union(yPred).ToList();
            classes.Sort();
            int[,] confMat = new int[classes.Count, classes.Count];
            for (int i = 0; i < yTrue.Length; i++)
            {
                confMat[classes.IndexOf(yTrue[i]), classes.IndexOf(yPred[i])] += 1;
            }
            return confMat;
        }



    }
}
