Classify() public method

public Classify ( IMLData input ) : int
input IMLData
return int
Exemplo n.º 1
0
        public void TestSOM()
        {
            // create the training set
            IMLDataSet training = new BasicMLDataSet(
                SOMInput, null);

            // Create the neural network.
            var network = new SOMNetwork(4, 2) {Weights = new Matrix(MatrixArray)};

            var train = new BasicTrainSOM(network, 0.4,
                                          training, new NeighborhoodSingle()) {ForceWinner = true};

            int iteration = 0;

            for (iteration = 0; iteration <= 100; iteration++)
            {
                train.Iteration();
            }

            IMLData data1 = new BasicMLData(
                SOMInput[0]);
            IMLData data2 = new BasicMLData(
                SOMInput[1]);

            int result1 = network.Classify(data1);
            int result2 = network.Classify(data2);

            Console.WriteLine(result1 + " result 2 :"+result2);
            Assert.IsTrue(result1 != result2);
        }
Exemplo n.º 2
0
        public void TestSOM2()
        {
            // create the training set
            IMLDataSet training = new BasicMLDataSet(
                SOMInput2, null);

            // Create the neural network.
            var network = new SOMNetwork(4,4);

            var train = new BasicTrainSOM(network, 0.01,
                                       training, new NeighborhoodSingle()) { ForceWinner = true };

            int iteration = 0;

            for (iteration = 0; iteration <= 1000; iteration++)
            {
                train.Iteration();
            }

            IMLData data1 = new BasicMLData(
                SOMInput2[2]);
            IMLData data2 = new BasicMLData(
                SOMInput2[0]);

            IMLData data3 = new BasicMLData(
               SOMInput2[1]);
            IMLData data4 = new BasicMLData(
                SOMInput2[3]);

            int result1 = network.Classify(data1);
            int result2 = network.Classify(data2);
            int result3 = network.Classify(data3);
            int result4 = network.Classify(data4);

            Console.WriteLine("Winner in someinput 2 "+network.Winner(new BasicMLData(SOMInput2[0])));

            Console.WriteLine("First  :" +result1);
            Console.WriteLine("Second "+result2);
            Console.WriteLine("Third  :" + result3);
            Console.WriteLine("Fourth " + result4);

            Assert.IsTrue(result1 != result2);

            train.TrainPattern(new BasicMLData(SOMInput2[2]));
            Console.WriteLine("After training pattern: " + network.Winner(new BasicMLData(SOMInput2[1])));

            var result = new SupportVectorMachine(4, SVMType.SupportVectorClassification, KernelType.Sigmoid);
            training = new BasicMLDataSet(
                SOMInput2, SOMInput2);
            SVMTrain trainsvm = new SVMTrain(result, training);

            trainsvm.Iteration(50);

            result1 = result.Classify(data1);

            result2 = result.Classify(data2);
            result3 = result.Classify(data3);
            result4 = result.Classify(data4);

            Console.WriteLine("SVM classification : EURUSD 1 :"+result1 + "  GBPUSD:"+result2 + " EURCHF :"+result3+  " EURJPY:"+result4 );
        }