private void runIrisNetwork()
        {
            //Getting data set ready:
            bool normalize = selectedNetwork == typeof(LMS);

            irisSet     = new DataSetReader("../../../DataSets/iris.data", DataSetType.IRIS, normalize);
            graphDrawer = new GraphDrawer(irisSet, graphPictureBox, irisBrushes);

            //Network parameters:
            target   = new double[] { -1, 1 };
            features = new double[] { (int)numFeatureOne.Value, (int)numFeatureTwo.Value };
            classes  = new double[] { (int)numClassOne.Value, (int)numClassTwo.Value };
            double eta  = (double)numEta.Value;
            double bias = 1.0;

            //Selecting the right network:
            if (selectedNetwork == typeof(Perceptron))
            {
                machine = new Perceptron(irisSet, target, eta, bias, features, classes);
            }
            else if (selectedNetwork == typeof(LMS))
            {
                machine = new LMS(irisSet, target, eta, bias, features, classes);
            }

            //Train the network:
            machine.train(30);

            //Test the network:
            int[,] testMatrix = machine.test(20);
            UiTools.drawMatrix(dataGridView, testMatrix);
            lblAccuracy.Text = VectorTools.confusionAccuracy(testMatrix).ToString();
        }
Пример #2
0
        private void startIrisMachine()
        {
            Layer hidden = new Layer(
                new Neuron[] {
                new Neuron(VectorTools.zeros(4), 1, 0, ActivationFunctions.sigmoid, ActivationFunctions.sigmoidDiff),
                new Neuron(VectorTools.zeros(4), 1, 0, ActivationFunctions.sigmoid, ActivationFunctions.sigmoidDiff),
                new Neuron(VectorTools.zeros(4), 1, 0, ActivationFunctions.sigmoid, ActivationFunctions.sigmoidDiff)
            }
                );
            Layer output = new Layer(
                new Neuron[] {
                new Neuron(VectorTools.zeros(3), 1, 0, ActivationFunctions.sigmoid, ActivationFunctions.sigmoidDiff),
                new Neuron(VectorTools.zeros(3), 1, 0, ActivationFunctions.sigmoid, ActivationFunctions.sigmoidDiff),
                new Neuron(VectorTools.zeros(3), 1, 0, ActivationFunctions.sigmoid, ActivationFunctions.sigmoidDiff)
            }
                );

            double eta    = (double)numEta.Value;
            int    epochs = (int)numMaxEpochs.Value;

            network = new BackPropagation(new Layer[] { hidden, output }, irisSet, eta, epochs);

            network.train(30);
            int[,] testMatrix = network.test(20);

            UiTools.drawMatrix(gridConfMatrix, testMatrix);
            double accuracy = VectorTools.confusionAccuracy(testMatrix);

            lblAccuracy.Text = Math.Round(accuracy, 4).ToString();
        }