Exemplo n.º 1
0
        public void DisplayItems()
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)(DisplayItems));
                return;
            }

            ShownItems = new Audios(Core.GetAudios());//temp !!!!!

            pnAudios.Build(ShownItems);
            lbItemCount.Text = "Items: " + ShownItems.Count;
            Invalidate(true);
        }
Exemplo n.º 2
0
        public EstimationResult EstimateAlgorithm(ISearchAlgorithm algorithm, object parameters = null)
        {
            if (algorithm == null)
            {
                throw new ArgumentNullException("algorithm");
            }

            Dictionary <SHA1Hash, Dictionary <SHA1Hash, int> > AutoScores = new Dictionary <SHA1Hash, Dictionary <SHA1Hash, int> >();

            List <Audio> Audios        = Core.GetAudios().ToList();
            List <Audio> ReferenceList = Audios.ToList();

            foreach (Audio ReferenceAudio in ReferenceList)
            {
                IList <Audio> Series = Audios.Search(ReferenceAudio, algorithm, parameters)
                                       .Where(audio => HashMap.Contains(audio.GetHash()))
                                       .ToList();

                SHA1Hash ReferenceHash = ReferenceAudio.GetHash();

                AutoScores.Add(ReferenceHash, new Dictionary <SHA1Hash, int>());

                int Rank = 0;
                foreach (Audio TargetAudio in Series)
                {
                    AutoScores[ReferenceHash].Add(TargetAudio.GetHash(), TransformRankToScore(Rank++, Series.Count));
                }
            }

            List <double> Errors                = new List <double>();
            List <double> ManualScoresList      = new List <double>();
            List <double> ReducedAutoScoresList = new List <double>();

            foreach (SHA1Hash Reference in ManualScores.Keys)
            {
                foreach (SHA1Hash Target in ManualScores[Reference].Keys)
                {
                    if (AutoScores.ContainsKey(Reference) && AutoScores[Reference].ContainsKey(Target))
                    {
                        int ReferenceScore = ManualScores[Reference][Target];

                        int AutoScore = AutoScores[Reference][Target];

                        int Error = ReferenceScore - AutoScore;

                        Errors.Add(Error);
                        ManualScoresList.Add(ReferenceScore);
                        ReducedAutoScoresList.Add(AutoScore);
                    }
                }
            }

            double Mean = Errors.Mean();

            double StandardDeviation = Errors.StandardDeviation();

            double Covariance   = ManualScoresList.Covariance(ReducedAutoScoresList);
            double PearsonCoeff = Correlation.Pearson(ManualScoresList, ReducedAutoScoresList);

            EstimationResult Result = new EstimationResult()
            {
                AlgorithmName     = algorithm.DisplayName,
                Parameters        = Convert.ToString(parameters),
                Mean              = Mean,
                StandardDeviation = StandardDeviation,
                Covariance        = Covariance,
                PearsonCoeff      = PearsonCoeff,
                Scores            = AutoScores
            };

            return(Result);
        }