private void ShowModelResult(ModelResult modelResult)
        {
            StringBuilder output = new StringBuilder();

            output.AppendLine(modelResult.ModelTitle);
            output.AppendLine();

            if (modelResult.PredictedDefectFiles != null)
            {
                bool evaluated = modelResult.DefectFiles != null;

                output.AppendLine("Predicted defect files:");
                foreach (var f in modelResult.PredictedDefectFiles)
                {
                    output.AppendLine(
                        string.Format("{0} {1}", f, evaluated ? modelResult.DefectFiles.Contains(f) ? "+" : "-" : "")
                        );
                }

                if (evaluated)
                {
                    output.AppendLine("Defect files:");
                    foreach (var f in modelResult.DefectFiles.OrderBy(x => x))
                    {
                        output.AppendLine(
                            string.Format("{0} {1}", f, modelResult.PredictedDefectFiles.Contains(f) ? "+" : "-")
                            );
                    }
                }
            }

            if (modelResult.ER != null)
            {
                output.AppendLine(EvaluationResultToString(modelResult.ER));
            }
            if (modelResult.RoER != null)
            {
                output.AppendLine(RocEvaluationResultToString(modelResult.RoER));
            }
            if (modelResult.RaER != null)
            {
                output.AppendLine(RankingEvaluationResultToString(modelResult.RaER));
            }
            if (modelResult.FileEstimations != null)
            {
                output.AppendLine(FileEstimationsToString(
                                      Accord.Statistics.Tools.Mean(modelResult.FileEstimations),
                                      Accord.Statistics.Tools.Median(modelResult.FileEstimations),
                                      modelResult.FileEstimations.Max(),
                                      modelResult.FileEstimations.Min()
                                      ));
            }
            output.AppendLine();
            OnAddReport(output.ToString());
        }
        private IEnumerable <ModelResult> Predict(IDictionary <string, string> releases)
        {
            ModelResult modelResult;

            foreach (var model in SelectedModels)
            {
                modelResult            = new ModelResult();
                modelResult.ModelTitle = model.Title;

                using (var s = predictor.Data.OpenSession())
                {
                    model.Init(s, releases.Keys);
                    model.Predict();

                    if (ShowFiles)
                    {
                        modelResult.PredictedDefectFiles = model.PredictedDefectFiles.ToArray();
                    }
                    if (Evaluate || EvaluateUsingROC)
                    {
                        modelResult.DefectFiles = model.DefectFiles.ToArray();
                    }
                    if (Evaluate)
                    {
                        modelResult.ER = model.Evaluate();
                    }
                    if (EvaluateUsingROC)
                    {
                        modelResult.RoER = model.EvaluateUsingROC();
                        rocs.Add(modelResult.RoER);
                        OnRocAdded(model.Title, releases.Last().Value, rocs.Count - 1);
                    }
                    if (EvaluateRanking)
                    {
                        modelResult.RaER = model.EvaluateRanking();
                    }
                    if (ShowEstimationStats)
                    {
                        modelResult.FileEstimations = model.FileEstimations;
                    }
                }

                ShowModelResult(modelResult);
                yield return(modelResult);
            }
        }