private Dictionary <GestureType, Result> DoExperimentOnDataset(Dictionary <GestureType, List <GestureSample> > RecognitionSamples,
                                                                       string experimentName)
        {
            Dictionary <GestureType, Result> accuracy = new Dictionary <GestureType, Result>();

            Console.WriteLine("*********************************************************************************");
            Console.WriteLine("Running User Independent Experiment(" + ExperimentNo + ") On :  " + experimentName);

            //do classification on Samples
            foreach (GestureType gType in Config.GesturesToUse)
            {
                List <GestureSample> samplesToRecognize = RecognitionSamples[gType];

                accuracy.Add(gType, new Result());
                accuracy[gType].Total = samplesToRecognize.Count;

                foreach (GestureSample gSample in samplesToRecognize)
                {
                    GestureType classification = Recognizer.Classify(gSample);
                    if (classification == gType)
                    {
                        accuracy[gType].Correct++;
                    }
                }

                Console.WriteLine("Accuracy[" + gType + "] : " + accuracy[gType].Correct + "/" + accuracy[gType].Total + " ~= " + accuracy[gType].Accuracy);
            }

            //report accuracy
            float average = 0.0f;
            float min = float.PositiveInfinity, max = float.NegativeInfinity;

            foreach (GestureType gType in Config.GesturesToUse)
            {
                average += accuracy[gType].Accuracy;
                if (accuracy[gType].Accuracy > max)
                {
                    max = accuracy[gType].Accuracy;
                }
                if (accuracy[gType].Accuracy < min)
                {
                    min = accuracy[gType].Accuracy;
                }
            }

            Console.WriteLine(String.Format("accuracy: {0}, \t[Min: {1}, Max: {2}]", (average / (float)Config.GesturesToUse.Count), min, max));
            Console.WriteLine("*********************************************************************************");

            return(accuracy);
        }
Beispiel #2
0
        public static void TestLC()
        {
            //double[][] input = new double[][]
            //{
            //    new double[]{0,0,0},
            //    new double[]{0,0,1},
            //    new double[]{0,1,0},
            //    new double[]{0,1,1},

            //    new double[]{1,0,0},
            //    new double[]{1,0,1},
            //    new double[]{1,1,0},
            //    new double[]{1,1,1}
            //};

            //bool[] result = new bool[]
            //{
            //    false,
            //    false,
            //    false,
            //    false,

            //    false,
            //    false,
            //    false,
            //    true
            //};

            double[][] input = new double[][]
            {
                new double[] { 0, 0 },
                new double[] { 0, 1 },
                new double[] { 1, 0 },
                new double[] { 1.1, 1.1 }
            };

            bool[] result = new bool[]
            {
                true,
                false,
                false,
                true
            };

            LinearClassifier LC = new LinearClassifier(input, result);

            while (true)
            {
                try
                {
                    Console.WriteLine("Eingabe: ");
                    double[] loop = new double[2];

                    for (int i = 0; i < 2; ++i)
                    {
                        loop[i] = Convert.ToDouble(Console.ReadLine());
                    }

                    Console.WriteLine("Ergebniss: " + LC.Classify(loop).ToString());
                }
                catch
                {
                    Console.WriteLine("Fehler bei der Eingabe");
                }
            }
        }