internal static List <BinaryClassificationMetrics> FromMetrics(IHostEnvironment env, IDataView overallMetrics, IDataView confusionMatrix, int confusionMatriceStartIndex = 0)
        {
            Contracts.AssertValue(env);
            env.AssertValue(overallMetrics);
            env.AssertValue(confusionMatrix);

            var metricsEnumerable = overallMetrics.AsEnumerable <SerializationClass>(env, true, ignoreMissingColumns: true);

            if (!metricsEnumerable.GetEnumerator().MoveNext())
            {
                throw env.Except("The overall RegressionMetrics didn't have any rows.");
            }

            List <BinaryClassificationMetrics> metrics = new List <BinaryClassificationMetrics>();
            var confusionMatrices = ConfusionMatrix.Create(env, confusionMatrix).GetEnumerator();

            int index = 0;

            foreach (var metric in metricsEnumerable)
            {
                if (index++ >= confusionMatriceStartIndex && !confusionMatrices.MoveNext())
                {
                    throw env.Except("Confusion matrices didn't have enough matrices.");
                }

                metrics.Add(
                    new BinaryClassificationMetrics()
                {
                    Auc               = metric.Auc,
                    Accuracy          = metric.Accuracy,
                    PositivePrecision = metric.PositivePrecision,
                    PositiveRecall    = metric.PositiveRecall,
                    NegativePrecision = metric.NegativePrecision,
                    NegativeRecall    = metric.NegativeRecall,
                    LogLoss           = metric.LogLoss,
                    LogLossReduction  = metric.LogLossReduction,
                    Entropy           = metric.Entropy,
                    F1Score           = metric.F1Score,
                    Auprc             = metric.Auprc,
                    RowTag            = metric.RowTag,
                    ConfusionMatrix   = confusionMatrices.Current,
                });
            }

            return(metrics);
        }
        internal static List <ClassificationMetrics> FromMetrics(IHostEnvironment env, IDataView overallMetrics, IDataView confusionMatrix,
                                                                 int confusionMatriceStartIndex = 0)
        {
            Contracts.AssertValue(env);
            env.AssertValue(overallMetrics);
            env.AssertValue(confusionMatrix);

            var metricsEnumerable = overallMetrics.AsEnumerable <SerializationClass>(env, true, ignoreMissingColumns: true);

            if (!metricsEnumerable.GetEnumerator().MoveNext())
            {
                throw env.Except("The overall RegressionMetrics didn't have any rows.");
            }

            List <ClassificationMetrics> metrics = new List <ClassificationMetrics>();
            var confusionMatrices = ConfusionMatrix.Create(env, confusionMatrix).GetEnumerator();

            int index = 0;

            foreach (var metric in metricsEnumerable)
            {
                if (index++ >= confusionMatriceStartIndex && !confusionMatrices.MoveNext())
                {
                    throw env.Except("Confusion matrices didn't have enough matrices.");
                }

                metrics.Add(
                    new ClassificationMetrics()
                {
                    AccuracyMicro    = metric.AccuracyMicro,
                    AccuracyMacro    = metric.AccuracyMacro,
                    LogLoss          = metric.LogLoss,
                    LogLossReduction = metric.LogLossReduction,
                    TopKAccuracy     = metric.TopKAccuracy,
                    PerClassLogLoss  = metric.PerClassLogLoss,
                    ConfusionMatrix  = confusionMatrices.Current,
                    RowTag           = metric.RowTag,
                });
            }

            return(metrics);
        }