Ejemplo n.º 1
0
        public override double Test(Signature signature)
        {
            var debugInfo = (List <object[]>)Logger.ObjectEntries[signature.Signer.ID + "-fusclassifier-distances"];
            var debugRow  = new object[originals.Count + 1];

            debugRow[0] = signature.ID;

            double avg = 0;

            int count = originals.Count;

            for (int j = 0; j < originals.Count; j++)
            {
                if (signature == originals[j])
                {
                    count--;
                }
                else
                {
                    var dist = FusedScore.CalculateFusionOfDtwAndWPathScore(signature, new Signature[] { originals[j] }, InputFeatures);
                    avg            += dist;
                    debugRow[j + 1] = dist;
                }
            }
            debugInfo.Add(debugRow);
            return(CalculateTestResult(avg / count, threshold));
        }
Ejemplo n.º 2
0
        private void CalculateSimilarity()
        {
            SimilarityResults = new List <SimilarityResult>(trainSignatures.Count);
            for (int i = 0; i < trainSignatures.Count; i++)
            {
                var trainSig = trainSignatures[i];

                double avg   = 0;
                int    count = referenceSignatures.Count;
                for (int j = 0; j < referenceSignatures.Count; j++)
                {
                    if (trainSig == referenceSignatures[j])
                    {
                        count--;
                    }
                    else
                    {
                        var dist = FusedScore.CalculateFusionOfDtwAndWPathScore(trainSig, new Signature[] { referenceSignatures[j] }, InputFeatures);
                        avg += dist;
                        debugInfo[i + 1, j + 1] = dist;
                    }
                }

                double avgDist = avg / count;
                SimilarityResults.Add(new SimilarityResult(trainSig, avgDist));
            }
        }
Ejemplo n.º 3
0
        public override double Train(List <Signature> signatures)
        {
            if (signatures == null)
            {
                throw new ArgumentNullException(nameof(signatures));
            }
            if (signatures.Count == 0)
            {
                throw new ArgumentException("'sigantures' can not be empty", nameof(signatures));
            }

            originals = signatures;
            List <double> costs = new List <double>(originals.Count);
            double        avg   = 0;
            double        n     = 0;

            List <object[]> debugInfo = new List <object[]>();
            //new object[originals.Count + 1, originals.Count + 1];

            var debugRow = new object[signatures.Count + 1];

            for (int i = 0; i < originals.Count; i++)
            {
                debugRow[i + 1] = signatures[i].ID;
            }
            debugInfo.Add(debugRow);

            for (int i = 0; i < originals.Count - 1; i++)
            {
                debugRow    = new object[signatures.Count + 1];
                debugRow[0] = signatures[i].ID;
                for (int j = i + 1; j < originals.Count; j++)
                {
                    double cost = FusedScore.CalculateFusionOfDtwAndWPathScore(originals[i], new Signature[] { originals[j] }, InputFeatures);
                    debugRow[j + 1] = cost;
                    avg            += cost;
                    costs.Add(cost);

                    n++;
                }
                debugInfo.Add(debugRow);
            }

            avg /= n;

            double dev = Measures.StandardDeviation(costs.ToArray(), false);

            threshold = avg + 0.8 * dev; //TODO: rendesen beállítani, valami adaptívabbat kitaláltni

            Logger.Info(this, signatures[0].Signer.ID + "-fusclassifier-distances", debugInfo);

            return(threshold);
        }
Ejemplo n.º 4
0
        //Azokat a dolgokat amiket a verifier előfeldolgoz itt nincsenek csak részben
        //a loadsignature-ben van valami minimáis előfeldolgozás
        private void GoDTWButton_Click(object sender, RoutedEventArgs e)
        {
            if (Signers == null)
            {
                LoadSignatures();
            }

            Signature signature1 = Signers[(int)SignerComboBox1.SelectedValue - 1].Signatures[(int)SignatureComboBox1.SelectedIndex];
            Signature signature2 = Signers[(int)SignerComboBox2.SelectedValue - 1].Signatures[(int)SignatureComboBox2.SelectedIndex];

            //DTWScoreTextBlock.Text = Analyzer.GetCost(sig1, sig2, true).Cost.ToString();
            Dtw dtw = new Dtw(signature1, signature2, FeatureFilter);

            OwnDTWScoreTextBlock.Text      = dtw.CalculateDtwScore().ToString();
            WarpingPathScoreTextBlock.Text = dtw.CalculateWarpingPathScore().ToString();
            FusionScoreTextBlock.Text      = FusedScore.CalculateFusionOfDtwAndWPathScore(signature1, new Signature[] { signature2 }, FeatureFilter).ToString();
        }
Ejemplo n.º 5
0
 public override double Test(Signature signature)
 {
     return(CalculateTestResult(FusedScore.CalculateFusionOfDtwAndWPathScore(signature, referenceSignatures.ToArray(), InputFeatures), threshold));
 }