Beispiel #1
0
        public void AnimalClassifyMethod()
        {
            DataSetLoader          dataSetLoader          = new DataSetLoader();
            var                    animals                = dataSetLoader.SelectAnimals();
            var                    data                   = dataSetLoader.CalculatePercent(50, animals);
            DecisionTreeClassifier decisionTreeClassifier =
                new DecisionTreeClassifier(data.Item1, new ShannonEntropySplitter());
            NaiveBayesClassifier naiveBayes =
                new NaiveBayesClassifier(data.Item1);
            var           list   = new List <NetML.Classification>();
            Kernel        kernel = new LinearKernel();
            SVMClassifier animalSVMClassifier =
                new SVMClassifier(animals, kernel, 0.001, 10.0);
            var neuronalAnimals = dataSetLoader.SelectNeuronalNetworkAnimals();
            NeuronalNetworkClassifier neuronalNetworkClassifier =
                new NeuronalNetworkClassifier(neuronalAnimals, 16, 7, 16, 500, 0.1);

            list.Add(decisionTreeClassifier);
            list.Add(naiveBayes);
            list.Add(animalSVMClassifier);
            list.Add(neuronalNetworkClassifier);
            Classifier classifier = new Classifier();

            classifier.Classify(list, data.Item2);
        }
        public void AnimalRadialBasisFunctionNeuronalNetworkClassifierTest()
        {
            DataSetLoader dataSetLoader = new DataSetLoader();

            Console.WriteLine(" Reading DataSet.. ");
            var animals = dataSetLoader.SelectNeuronalNetworkAnimals();

            for (double i = 0; i < 1; i = i + 1)
            {
                OneHiddenLayerNeuronCounter        oneHiddenLayerNeuronCounter = new OneHiddenLayerNeuronCounter(16, 8, 32);
                RadialBasisFunctionNeuronalNetwork radialBasisFunctionNeuronalNetworkClassifier =
                    new RadialBasisFunctionNeuronalNetwork(oneHiddenLayerNeuronCounter, 10000, 0.5);
                radialBasisFunctionNeuronalNetworkClassifier.Train(animals);
                var animalsTest = dataSetLoader.SelectAnimals();
                var trueCounter = 0;
                var counter     = 0;
                foreach (var item in animalsTest)
                {
                    var    outputValue  = radialBasisFunctionNeuronalNetworkClassifier.Classify(item.Item1);
                    var    resultString = String.Empty;
                    double maxValue     = 0.0;
                    int    innerCounter = 1;
                    int    maxItem      = 0;
                    foreach (var value in outputValue.OutputValues)
                    {
                        if (value > maxValue)
                        {
                            maxValue = value;
                            maxItem  = innerCounter;
                        }
                        innerCounter++;
                    }
                    if (maxItem == item.Item2)
                    {
                        trueCounter++;
                    }
                    Debug.WriteLine(string.Format("Value {0} - Predicted {1} {2} {3} {4} {5} {6} {7} = {8}",
                                                  item.Item2,
                                                  Convert.ToDecimal(outputValue.OutputValues[0]),
                                                  Convert.ToDecimal(outputValue.OutputValues[1]),
                                                  Convert.ToDecimal(outputValue.OutputValues[2]),
                                                  Convert.ToDecimal(outputValue.OutputValues[3]),
                                                  Convert.ToDecimal(outputValue.OutputValues[4]),
                                                  Convert.ToDecimal(outputValue.OutputValues[5]),
                                                  Convert.ToDecimal(outputValue.OutputValues[6]),
                                                  (maxItem == item.Item2) ? "true" : "false"));
                    counter++;
                }
                Debug.WriteLine(string.Format(" i = {0} Data {1} - True {2} Verhältnis: {3}", i,
                                              counter.ToString(), trueCounter.ToString(), (Convert.ToDouble(trueCounter) / Convert.ToDouble(counter)).ToString()));
            }
        }
Beispiel #3
0
        public void AnimalNeuronalNetworkClassifierTest()
        {
            DataSetLoader dataSetLoader = new DataSetLoader();

            Console.WriteLine(" Reading DataSet.. ");
            var animals = dataSetLoader.SelectNeuronalNetworkAnimals();

            for (double i = 0; i < 1; i = i + 1)
            {
                NeuronalNetworkClassifier neuronalNetworkClassifier =
                    new NeuronalNetworkClassifier(animals, 16, 7, 16, 900, 0.1, NeuronalNetworkMode.Standard);
                neuronalNetworkClassifier.Train();
                var animalsTest = dataSetLoader.SelectAnimals();
                var trueCounter = 0;
                var counter     = 0;
                foreach (var item in animalsTest)
                {
                    var    outputValue  = neuronalNetworkClassifier.ClassifiyMultibleResultValue(item.Item1);
                    var    resultString = String.Empty;
                    double maxValue     = 0.0;
                    int    innerCounter = 1;
                    int    maxItem      = 0;
                    foreach (var value in outputValue)
                    {
                        if (value > maxValue)
                        {
                            maxValue = value;
                            maxItem  = innerCounter;
                        }
                        innerCounter++;
                    }
                    if (maxItem == item.Item2)
                    {
                        trueCounter++;
                    }
                    Debug.WriteLine(string.Format("Value {0} - Predicted {1} = {2}",
                                                  item.Item2, maxItem, (maxItem == item.Item2) ? "true" : "false"));
                    counter++;
                }
                Debug.WriteLine(string.Format(" i = {0} Data {1} - True {2} Verhältnis: {3}", i,
                                              counter.ToString(), trueCounter.ToString(), (Convert.ToDouble(trueCounter) / Convert.ToDouble(counter)).ToString()));
            }
        }