Пример #1
0
        public void CreditDataClassifyMethod()
        {
            DataSetLoader          dataSetLoader          = new DataSetLoader();
            var                    creditData             = dataSetLoader.SelectCreditData();
            var                    data                   = dataSetLoader.CalculatePercent(100, creditData);
            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 SVMClassifier =
                new SVMClassifier(creditData, kernel, 0.001, 10.0);
            var neuronalCreditData = dataSetLoader.SelectNeuronalNetworksCreditData();
            NeuronalNetworkClassifier neuronalNetworkClassifier =
                new NeuronalNetworkClassifier(neuronalCreditData, 20, 2, 20, 5000, 0.1);

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

            classifier.Classify(list, creditData);
        }
Пример #2
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 SanFranciscoCrimeClassificationTestDataSetTest()
        {
            DataSetLoader dataSetLoader = new DataSetLoader();

            Console.WriteLine(" Reading DataSet.. ");
            var crimes = dataSetLoader.SelectNeuronalNetworkCrimes();
            //DecisionTreeClassifier decisionTreeClassifier =
            //new DecisionTreeClassifier(crimes, new ShannonEntropySplitter());
            NeuronalNetworkClassifier neuronalNetworkClassifier =
                new NeuronalNetworkClassifier(crimes, 2, 38, 2, 5000, 0.1);

            //Kernel kernel = new LinearKernel();
            //NaiveBayesClassifier naiveBayes =
            //        new NaiveBayesClassifier(crimes);
            neuronalNetworkClassifier.Train();
            var crimeTests  = dataSetLoader.SelectCrimes();
            var trueCounter = 0;
            var counter     = 0;

            foreach (var item in crimeTests)
            {
                var    outputValue  = neuronalNetworkClassifier.ClassifiyMultibleResultValue(item.Item1);
                var    resultString = String.Empty;
                double maxValue     = 0.0;
                int    innerCounter = 0;
                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("Data {0} - True {1} Verhältnis: {2}",
                                          counter.ToString(), trueCounter.ToString(), (Convert.ToDouble(trueCounter) / Convert.ToDouble(counter)).ToString()));
        }
Пример #4
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()));
            }
        }
Пример #5
0
        public void MushroomsNeuronalNetworkMachineTrainAndClassify8020Test()
        {
            DataSetLoader dataSetLoader = new DataSetLoader();

            Console.WriteLine(" Reading DataSet.. ");
            var mushroom = dataSetLoader.SelectNeuronalNetworksTrainingMushroom(80);

            for (double i = 0; i < 1; i = i + 1)
            {
                NeuronalNetworkClassifier neuronalNetworkClassifier =
                    new NeuronalNetworkClassifier(mushroom, 21, 2, 21, 50, 0.2);
                neuronalNetworkClassifier.Train();
                var mushroomTest = dataSetLoader.SelectNeuronalNetworksSelectingMushroom(20);
                var trueCounter  = 0;
                var counter      = 0;
                foreach (var item in mushroomTest)
                {
                    var    outputValue  = neuronalNetworkClassifier.ClassifiyMultibleResultValue(item.Item1);
                    var    resultString = String.Empty;
                    double maxValue     = 0.0;
                    int    innerCounter = 0;
                    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()));
            }
        }
Пример #6
0
        public void XorNeuronalNetworkClassifierTest()
        {
            List <Tuple <double[], double> > xorValues = new List <Tuple <double[], double> >();

            xorValues.Add(new Tuple <double[], double>(new double[] { 0.0, 0.0 }, 1.0));
            xorValues.Add(new Tuple <double[], double>(new double[] { 1.0, 0.0 }, 0.0));
            xorValues.Add(new Tuple <double[], double>(new double[] { 0.0, 1.0 }, 0.0));
            xorValues.Add(new Tuple <double[], double>(new double[] { 1.0, 1.0 }, 1.0));
            NeuronalNetworkClassifier neuronalNetworkClassifier =
                new NeuronalNetworkClassifier(xorValues, 2, 4, 2, 500, 0.7, NeuronalNetworkMode.Cascade);

            neuronalNetworkClassifier.Train();
            var trueCounter = 0;
            var counter     = 0;

            foreach (var item in xorValues)
            {
                var    outputValue  = neuronalNetworkClassifier.ClassifiyMultibleResultValue(item.Item1);
                var    resultString = String.Empty;
                double maxValue     = 0.0;
                int    innerCounter = 0;
                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("Data {0} - True {1} Verhältnis: {2}",
                                          counter.ToString(), trueCounter.ToString(), (Convert.ToDouble(trueCounter) / Convert.ToDouble(counter)).ToString()));
        }