コード例 #1
0
ファイル: HMM.cs プロジェクト: tdav/emocije
        protected override void Classify()
        {
            for (int i = 0; i < FinalFeatures.Count(); i++)
            {
                if (Double.IsNaN(FinalFeatures[i]))
                {
                    FinalFeatures[i] = 0;
                }
            }

            if (MakeHTK(FinalFeatures, "1.htk", 0.001f))
            {
                string f = "-n 5 5 -C hvite.conf -H macros -H models.mmf -S testFiles.txt -l * -i result.mlf -w wordnet transcript classList";

                OpenHVITE(f);

                string pobjednik        = winner("result.mlf");
                EmoClassifierResult res = new EmoClassifierResult();

                res.Anger   = -prob[2];
                res.Sadness = -prob[1];
                res.Neutral = -prob[0];
                res.Joy     = -prob[4];
                res.Fear    = -prob[3];


                ClassifierEventArgs e = new ClassifierEventArgs();
                e.Result = res;
                ClassificationComplete.Invoke(this, e);
            }
        }
コード例 #2
0
ファイル: AbstractClassifier.cs プロジェクト: tdav/emocije
        private void ComputeSuperFeatures()
        {
            foreach (IFeature f in SubFeatures)
            {
                FastQueue <double> CurrentQueue = SubResults[f];
                List <double>      CurrentData  = CurrentQueue.Peek(SuperWindowLength);
                CurrentQueue.Delete(SuperWindowShift);
                DataProvider.Data = CurrentData;

                List <IFeature> CurrentSuperFeatures = SuperFeatures[f];
                foreach (IFeature superf in CurrentSuperFeatures)
                {
                    superf.Compute();
                    FinalFeatures.Add(superf.Feature);
                }
            }

            if (SuperFeaturesComputed != null)
            {
                SubFeaturesComputedEventArgs e = new SubFeaturesComputedEventArgs();
                e.ComputedFeatures = FinalFeatures;
                SuperFeaturesComputed.Invoke(this, e);
            }
            Classify();
            AllFeatures.Add(new List <double>(FinalFeatures));
            FinalFeatures.Clear();
            if (SubResults.First().Value.Count > SuperWindowLength)
            {
                ComputeSuperFeatures();
            }
        }
コード例 #3
0
        protected override void Classify()
        {
            for (int i = 0; i < FinalFeatures.Count(); i++)
            {
                if (Double.IsNaN(FinalFeatures[i]))
                {
                    FinalFeatures[i] = 0;
                }
            }
            Matrix x = new Matrix(11, 1);
            int    j = 0;

            foreach (int i in indices)
            {
                x[i, 0] = FinalFeatures[j++];
            }


            List <double> prob = new List <double>();

            for (int i = 0; i < 5; i++)
            {
                double aa = GaussDistrib.Probability(x, mus[i], sigmas[i]);
                prob.Add(weight[i] * aa);
            }


            EmoClassifierResult res = new EmoClassifierResult();

            res.Anger   = prob[0];
            res.Sadness = prob[1];
            res.Neutral = prob[2];
            res.Joy     = prob[3];
            res.Fear    = prob[4];


            ClassifierEventArgs e = new ClassifierEventArgs();

            e.Result = res;
            ClassificationComplete.Invoke(this, e);
        }