Exemplo n.º 1
0
        public void testDataSetPopulation()
        {
            DataSet              irisDataSet = DataSetFactory.getIrisDataSet();
            INumerizer           numerizer   = new IrisDataSetNumerizer();
            NeuralNetworkDataSet innds       = new IrisNeuralNetworkDataSet();

            innds.CreateExamplesFromDataSet(irisDataSet, numerizer);

            NeuralNetworkConfig config = new NeuralNetworkConfig();

            config.SetConfig(FeedForwardNeuralNetwork.NUMBER_OF_INPUTS, 4);
            config.SetConfig(FeedForwardNeuralNetwork.NUMBER_OF_OUTPUTS, 3);
            config.SetConfig(FeedForwardNeuralNetwork.NUMBER_OF_HIDDEN_NEURONS, 6);
            config.SetConfig(FeedForwardNeuralNetwork.LOWER_LIMIT_WEIGHTS, -2.0);
            config.SetConfig(FeedForwardNeuralNetwork.UPPER_LIMIT_WEIGHTS, 2.0);

            FeedForwardNeuralNetwork ffnn = new FeedForwardNeuralNetwork(config);

            ffnn.SetTrainingScheme(new BackPropagationLearning(0.1, 0.9));

            ffnn.TrainOn(innds, 10);

            innds.RefreshDataset();
            ffnn.TestOnDataSet(innds);
        }
Exemplo n.º 2
0
        internal static void backPropogationDemo()
        {
            try
            {
                DataSet              irisDataSet = DataSetFactory.getIrisDataSet();
                INumerizer           numerizer   = new IrisDataSetNumerizer();
                NeuralNetworkDataSet innds       = new IrisNeuralNetworkDataSet();

                innds.CreateExamplesFromDataSet(irisDataSet, numerizer);

                NeuralNetworkConfig config = new NeuralNetworkConfig();
                config.SetConfig(FeedForwardNeuralNetwork.NUMBER_OF_INPUTS, 4);
                config.SetConfig(FeedForwardNeuralNetwork.NUMBER_OF_OUTPUTS, 3);
                config.SetConfig(FeedForwardNeuralNetwork.NUMBER_OF_HIDDEN_NEURONS,
                                 6);
                config.SetConfig(FeedForwardNeuralNetwork.LOWER_LIMIT_WEIGHTS, -2.0);
                config.SetConfig(FeedForwardNeuralNetwork.UPPER_LIMIT_WEIGHTS, 2.0);

                FeedForwardNeuralNetwork ffnn = new FeedForwardNeuralNetwork(config);
                ffnn.SetTrainingScheme(new BackPropagationLearning(0.1, 0.9));

                ffnn.TrainOn(innds, 1000);

                innds.RefreshDataset();
                int[] result = ffnn.TestOnDataSet(innds);
                System.Console.WriteLine(result[0] + " right, " + result[1] + " wrong");
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 3
0
        public void testPerceptron()
        {
            DataSet              irisDataSet = DataSetFactory.getIrisDataSet();
            INumerizer           numerizer   = new IrisDataSetNumerizer();
            NeuralNetworkDataSet innds       = new IrisNeuralNetworkDataSet();

            innds.CreateExamplesFromDataSet(irisDataSet, numerizer);

            Perceptron perc = new Perceptron(3, 4);

            perc.TrainOn(innds, 10);

            innds.RefreshDataset();
            perc.TestOnDataSet(innds);
        }
Exemplo n.º 4
0
        public void testPerceptron()
        {
            DataSet   irisDataSet = DataSetFactory.getIrisDataSet();
            Numerizer numerizer   = new IrisDataSetNumerizer();
            NNDataSet innds       = new IrisNNDataSet();

            innds.createExamplesFromDataSet(irisDataSet, numerizer);

            Perceptron perc = new Perceptron(3, 4);

            perc.trainOn(innds, 10);

            innds.refreshDataset();
            perc.testOnDataSet(innds);
        }
Exemplo n.º 5
0
        public void testNumerizesAndDeNumerizesIrisDataSetExample3()


        {
            DataSet    ds    = DataSetFactory.getIrisDataSet();
            Example    first = ds.getExample(100);
            INumerizer n     = new IrisDataSetNumerizer();
            Pair <ICollection <double>, ICollection <double> > io = n.Numerize(first);

            Assert.AreEqual(CollectionFactory.CreateQueue <double>(new[] { 6.3, 3.3, 6.0, 2.5 }), io.GetFirst());
            Assert.AreEqual(CollectionFactory.CreateQueue <double>(new[] { 1.0, 0.0, 0.0 }), io.getSecond());

            string plant_category = n.Denumerize(CollectionFactory.CreateQueue <double>(new[] { 1.0, 0.0, 0.0 }));

            Assert.AreEqual("virginica", plant_category);
        }
Exemplo n.º 6
0
        public void testNumerizesAndDeNumerizesIrisDataSetExample2()


        {
            DataSet    ds    = DataSetFactory.getIrisDataSet();
            Example    first = ds.getExample(51);
            INumerizer n     = new IrisDataSetNumerizer();
            Pair <ICollection <double>, ICollection <double> > io = n.Numerize(first);

            Assert.AreEqual(CollectionFactory.CreateQueue <double>(new[] { 6.4, 3.2, 4.5, 1.5 }), io.GetFirst());
            Assert.AreEqual(CollectionFactory.CreateQueue <double>(new[] { 0.0, 1.0, 0.0 }), io.getSecond());

            string plant_category = n.Denumerize(CollectionFactory.CreateQueue <double>(new[] { 0.0, 1.0, 0.0 }));

            Assert.AreEqual("versicolor", plant_category);
        }
Exemplo n.º 7
0
        public void testNumerizesAndDeNumerizesIrisDataSetExample3()
        {
            DataSet   ds    = DataSetFactory.getIrisDataSet();
            Example   first = ds.getExample(100);
            Numerizer n     = new IrisDataSetNumerizer();
            Pair <List <Double>, List <Double> > io = n.numerize(first);

            AssertListsEqual <double>(new List <double>()
            {
                6.3, 3.3, 6.0, 2.5
            }, io.getFirst());
            AssertListsEqual <double>(new List <double>()
            {
                1.0, 0.0, 0.0
            }, io.getSecond());

            String plant_category = n.denumerize(new List <double>()
            {
                1.0, 0.0, 0.0
            });

            Assert.AreEqual("virginica", plant_category);
        }
Exemplo n.º 8
0
        public void testNumerizesAndDeNumerizesIrisDataSetExample2()
        {
            DataSet   ds    = DataSetFactory.getIrisDataSet();
            Example   first = ds.getExample(51);
            Numerizer n     = new IrisDataSetNumerizer();
            Pair <List <Double>, List <Double> > io = n.numerize(first);

            AssertListsEqual <double>(new List <double>()
            {
                6.4, 3.2, 4.5, 1.5
            }, io.getFirst());
            AssertListsEqual <double>(new List <double>()
            {
                0.0, 1.0, 0.0
            }, io.getSecond());

            String plant_category = n.denumerize(new List <double>()
            {
                0.0, 1.0, 0.0
            });

            Assert.AreEqual("versicolor", plant_category);
        }
Exemplo n.º 9
0
        static void perceptronDemo()
        {
            try
            {
                DataSet              irisDataSet = DataSetFactory.getIrisDataSet();
                INumerizer           numerizer   = new IrisDataSetNumerizer();
                NeuralNetworkDataSet innds       = new IrisNeuralNetworkDataSet();

                innds.CreateExamplesFromDataSet(irisDataSet, numerizer);

                Perceptron perc = new Perceptron(3, 4);

                perc.TrainOn(innds, 10);

                innds.RefreshDataset();
                int[] result = perc.TestOnDataSet(innds);
                System.Console.WriteLine(result[0] + " right, " + result[1] + " wrong");
            }
            catch (Exception e)
            {
                throw e;
            }
        }