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();
        }
Example #2
0
 public NeuralNetwork(DataSetReader dataSet, double[] target, double[] weight, double eta, double bias)
 {
     this.target      = target;
     this.data        = dataSet.data;
     this.featureMask = VectorTools.sequence(dataSet.features);
     this.classMask   = VectorTools.sequence(dataSet.classes);
     this.samples     = dataSet.samples;
     this.weight      = weight;
     this.eta         = eta;
     this.bias        = bias;
 }
Example #3
0
        protected const int MAX_EPOCHS = 1000;          //Limiting the number of iterations in the process.


        /*
         * CONSTRUCTORS
         */
        public NeuralNetwork(DataSetReader dataSet, double[] target, double bias, double eta)
        {
            this.target      = target;
            this.data        = dataSet.data;
            this.featureMask = VectorTools.sequence(dataSet.features);
            this.classMask   = VectorTools.sequence(dataSet.classes);
            this.weight      = VectorTools.ones(this.featureMask.Length + 1);        //+1 for bias.
            this.samples     = dataSet.samples;
            this.eta         = eta;
            this.bias        = bias;
        }
Example #4
0
        public NeuralNetwork(DataSetReader dataSet, double[] target, double eta, double bias, double[] featureMask, double[] classMask)
        {
            if (featureMask.Length > dataSet.features || featureMask.Length < 1)
            {
                throw new ArgumentOutOfRangeException("Number of features specified is not applicable");
            }

            this.target      = target;
            this.data        = dataSet.data;
            this.featureMask = featureMask;
            this.classMask   = classMask;
            this.weight      = VectorTools.ones(this.featureMask.Length + 1);        //+1 for bias.
            this.samples     = dataSet.samples;
            this.eta         = eta;
            this.bias        = bias;
        }
Example #5
0
 public LMS(DataSetReader dataSet, double[] target, double[] weight, double eta, double bias)
     : base(dataSet, target, weight, eta, bias)
 {
     checkNormalized(dataSet.normalized);
     this.data = dataSet.dataNorm;
 }
Example #6
0
 public LMS(DataSetReader dataSet, double[] target, double eta, double bias, double[] featureMask, double[] classMask)
     : base(dataSet, target, eta, bias, featureMask, classMask)
 {
     checkNormalized(dataSet.normalized);
     this.data = dataSet.dataNorm;
 }
Example #7
0
 public GraphDrawer(DataSetReader dataSet, PictureBox pictureBox, SolidBrush[] brush)
 {
     this.dataSet    = dataSet;
     this.pictureBox = pictureBox;
     this.brush      = brush;
 }
 /// <summary>Create a new perceptron machine.</summary>
 /// <param name="dataSet">Object holding the dataset to work on.</param>
 /// <param name="target">The target/goal vector for the training.</param>
 /// <param name="weight">The initial weight vector to start with.</param>
 /// <param name="eta">The learning rate.</param>
 /// <param name="bias">Initial bias value.</param>
 public Perceptron(DataSetReader dataSet, double[] target, double[] weight, double eta, double bias)
     : base(dataSet, target, weight, eta, bias)
 {
     //Nothing here.
 }
 /// <summary>Create a new perceptron machine.</summary>
 /// <param name="dataSet">Object holding the dataset to work on.</param>
 /// <param name="target">The target/goal vector for the training.</param>
 /// <param name="eta">The learning rate.</param>
 /// <param name="bias">Initial bias value.</param>
 /// <param name="featureMask">Set of features to use in the machine.</param>
 public Perceptron(DataSetReader dataSet, double[] target, double eta, double bias, double[] featureMask, double[] classMask)
     : base(dataSet, target, eta, bias, featureMask, classMask)
 {
     //Nothing here.
 }