public BoxSummaryData Calculate(SingleTracingResults singleTechniqueResults, TLDataset dataset)
        {
            SortedDictionary<string, double> intermediateResults = m_metricComputation.Calculate(singleTechniqueResults.ResultMatrix, dataset);

            double[] dataPoints = intermediateResults.Values.ToArray();
            if (dataPoints.Length == 0 && m_logger != null)
            {
                m_logger.Warn("Metric computation of '" + m_metricName + "' returned zero matching results for " + dataset.Name + " for one of the techniques. It may be valid results, but it may also mean that there is mismatch of ids in the answer matrix and corresponding artifacts." );
            }

            var summaryData = new BoxSummaryData(m_metricName, m_metricDescription);
            summaryData.AddPoint(new BoxPlotPoint(dataPoints));

            return summaryData;
        }
Exemple #2
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        ///   </exception>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            BoxSummaryData data = obj as BoxSummaryData;

            if ((System.Object)data == null)
            {
                return(false);
            }

            bool equal = MetricName == data.MetricName && Description == data.Description && Points.SequenceEqual(data.Points);

            return(equal);
        }
        public bool AddBox(BoxSummaryData b, string tecnnique)
        {
            bool boxAdded = false;

            IEnumerable<BoxPlotPoint> points = b.Points;
            foreach (BoxPlotPoint p in points)
            {
                if (0.0d <= p.Min && p.Max <= 1.0d && p.Min <= p.Q1 && p.Q1 <= p.Median && 
                    p.Median <= p.Q3 && p.Q3 <= p.Max)
                {
                    BoxData box = new BoxData(p.Min, p.Q1, p.Median, p.Q3, p.Max);
                    box.Name = tecnnique;
                    box.Color = Chart.Colors[this.boxes.Count % Chart.Colors.Length];
                    this.boxes.Add(box);
                    boxAdded = true;
                }
            }

            return boxAdded;
        }
Exemple #4
0
        public bool AddBox(BoxSummaryData b, string tecnnique)
        {
            bool boxAdded = false;

            IEnumerable<BoxPlotPoint> points = b.Points;
            foreach (BoxPlotPoint p in points)
            {
                if (p.Min <= p.Q1 && p.Q1 <= p.Median && p.Median <= p.Q3 && p.Q3 <= p.Max)
                {
                    BoxData box = new BoxData(p.Min, p.Q1, p.Median, p.Q3, p.Max);
                    box.Name = tecnnique;
                    box.Color = Chart.Colors[this.boxes.Count % Chart.Colors.Length];
                    this.boxes.Add(box);
                    boxAdded = true;
                    // check chart ranges
                    if (p.Min < this.chartStyle.Ymin)
                    {
                        this.chartStyle.Ymin = p.Min - 0.05;
                    }
                    if (p.Max > this.chartStyle.Ymax)
                    {
                        this.chartStyle.Ymax = p.Max + 0.05;
                    }
                    if (this.chartStyle.Ymin != -0.05d || this.chartStyle.Ymax != 1.05d)
                    {
                        this.chartStyle.YtickDelta = (this.chartStyle.Ymax - this.chartStyle.Ymin) / 10.0;
                    }
                }
                else
                {
                    throw new ComponentException(String.Format("Error in boxplot data.\nMin: {0}\nQ1: {1}\nMedian: {2}\nQ3: {3}\nMax: {4}",
                        p.Min, p.Q1, p.Median, p.Q3, p.Max
                    ));
                }
            }
            return boxAdded;
        }
 /// <summary>
 /// Generates a summarizing Metric for results analysis
 /// </summary>
 /// <returns>Metric object</returns>
 protected override Metric GenerateSummaryImplementation()
 {
     BoxSummaryData data = new BoxSummaryData(Name, Description);
     data.AddPoint(new BoxPlotPoint(Results.Values.ToArray()));
     return data;
 }
Exemple #6
0
 /// <summary>
 /// Adds a BoxSummary metric.
 /// </summary>
 /// <param name="metric">The metric.</param>
 public void AddBoxSummaryMetric(BoxSummaryData metric)
 {
     m_metrics.Add(metric);
 }
 /// <summary>
 /// Adds a BoxSummary metric.
 /// </summary>
 /// <param name="metric">The metric.</param>
 public void AddBoxSummaryMetric(BoxSummaryData metric)
 {
     m_metrics.Add(metric);
 }
        public void ExperimentResultsRawSerializationTest()
        {
            int n = 0;
            TLExperimentResults expResultsIn = new TLExperimentResults("Technique " + n++);
            for (int k = 0; k < 5; k++)
            {
                DatasetResults dataResults = new DatasetResults("Dataset " + n++);
                for (int i = 0; i < 10; i++)
                {
                    LineSeries line = new LineSeries("Line " + i, "Description " + n++);
                    for (int j = 1000 * i; j < 1000; j++)
                    {
                        line.AddPoint(new Point(j, j + 1));
                    }
                    dataResults.AddMetric(line);

                    BoxSummaryData box = new BoxSummaryData("Box " + i, "Description " + n++);
                    for (int j = 0; j < 100; j++)
                    {
                        box.AddPoint(new BoxPlotPoint(j, j + 1, j + 2, j + 3, j + 4, j + 5, j + 6, j + 7));
                    }
                    dataResults.AddMetric(box);
                }
                expResultsIn.AddDatasetResult(dataResults);
            }

            BinaryWriter binWriter = new BinaryWriter(new MemoryStream());
            BinaryReader binReader = new BinaryReader(binWriter.BaseStream);
            expResultsIn.WriteData(binWriter);
            binReader.BaseStream.Position = 0;
            TLExperimentResults expResultsOut = (TLExperimentResults)Activator.CreateInstance(typeof(TLExperimentResults), true);
            expResultsOut.ReadData(binReader);

            Assert.AreEqual(expResultsIn.TechniqueName, expResultsOut.TechniqueName);
            Assert.AreEqual(expResultsIn.DatasetsResults.Count(), expResultsOut.DatasetsResults.Count());

            foreach (DatasetResults result1 in expResultsIn.DatasetsResults)
            {
                bool sameDatasetResultExists = false;
                DatasetResults result2 = null;
                foreach (DatasetResults res in expResultsOut.DatasetsResults)
                {
                    if (res.DatasetName == result1.DatasetName)
                    {
                        sameDatasetResultExists = true;
                        result2 = res;
                        break;
                    }
                }
                Assert.IsTrue(sameDatasetResultExists);

                Assert.AreEqual(result1.DatasetName, result2.DatasetName);
                Assert.AreEqual(result1.Metrics.Count(), result2.Metrics.Count());

                foreach (Metric m1 in result1.Metrics)
                {
                    bool sameMetricExists = false;
                    Metric m2 = null;
                    foreach (Metric metric in result2.Metrics)
                    {
                        if (m1.MetricName == metric.MetricName)
                        {
                            sameMetricExists = true;
                            m2 = metric;
                            break;
                        }
                    }

                    Assert.IsTrue(sameMetricExists);
                    Assert.AreEqual(m1.Description, m2.Description);

                    if (m1 is LineSeries)
                    {
                        Assert.IsTrue(m2 is LineSeries);
                        LineSeries l1 = (LineSeries)m1;
                        LineSeries l2 = (LineSeries)m2;

                        Assert.AreEqual(l1.Points.Count(), l2.Points.Count());
                    }
                    else
                    {
                        Assert.IsTrue(m2 is BoxSummaryData);
                        BoxSummaryData b1 = (BoxSummaryData)m1;
                        BoxSummaryData b2 = (BoxSummaryData)m2;

                        Assert.AreEqual(b1.Points.Count(), b2.Points.Count());
                    }
                }
            }
        }