示例#1
0
        public void NaivebayersLanguageTest()
        {
            var           netMLString   = "create classification naivebayers linearbayeskernel";
            NetMLCreator  netMLCreator  = new NetMLCreator(netMLString);
            DataSetLoader dataSetLoader = new DataSetLoader();
            var           data          = dataSetLoader.SelectAnimals();

            netMLCreator.Create(data);
            netMLCreator.Train();
            var testData    = dataSetLoader.SelectAnimals();
            var trueCounter = 0;
            var counter     = 0;

            foreach (var item in testData)
            {
                var outputValue = netMLCreator.Classify(item.Item1);
                if (outputValue == item.Item2)
                {
                    trueCounter++;
                }
                Debug.WriteLine(string.Format("Value {0} - Predicted {1} = {2}",
                                              item.Item2, outputValue, (outputValue == item.Item2) ? "true" : "false"));
                counter++;
            }
            Debug.WriteLine(string.Format("Data {0} - True {1} Verhältnis: {2}",
                                          counter.ToString(), trueCounter.ToString(), (Convert.ToDouble(trueCounter) / Convert.ToDouble(counter)).ToString()));
        }
示例#2
0
        public void BackprobpagationLanguageTest()
        {
            var netMLString =
                "create classification backpropagation inputneurons = 16 outputneurons = 1 firsthiddenlayerneurons = 16 evolutions = 100 learningrate = 0.1 ";
            NetMLParser   netMLParser   = new NetMLParser();
            var           result        = netMLParser.Parse(netMLString);
            NetMLCreator  netMLCreator  = new NetMLCreator(result);
            DataSetLoader dataSetLoader = new DataSetLoader();
            var           data          = dataSetLoader.SelectAnimals();

            netMLCreator.Create(data);
            netMLCreator.Train();
            var testData    = dataSetLoader.SelectAnimals();
            var trueCounter = 0;
            var counter     = 0;

            foreach (var item in testData)
            {
                var outputValue = netMLCreator.Classify(item.Item1);
                if (outputValue == item.Item2)
                {
                    trueCounter++;
                }
                Debug.WriteLine(string.Format("Value {0} - Predicted {1} = {2}",
                                              item.Item2, outputValue, (outputValue == item.Item2) ? "true" : "false"));
                counter++;
            }
            Debug.WriteLine(string.Format("Data {0} - True {1} Verhältnis: {2}",
                                          counter.ToString(), trueCounter.ToString(), (Convert.ToDouble(trueCounter) / Convert.ToDouble(counter)).ToString()));
        }