Пример #1
0
        private void DualPerceptron(List <Tuple <double[], double> > data)
        {
            Kernel kernel = new LinearKernel();

            foreach (var item in netMLObject.Options)
            {
                if (item == "linearkernel")
                {
                    kernel = new LinearKernel();
                }
                else if (item == "gaussiankernel")
                {
                    kernel = new GaussianKernel(1.0);
                }
                else if (item == "polynomialkernel")
                {
                    kernel = new PolynomialKernel(1);
                }
                else if (item == "logitkernel")
                {
                    kernel = new LogitKernel();
                }
                else if (item == "tanhkernel")
                {
                    kernel = new TanhKernel();
                }
            }
            classification = new DualPerceptronClassifier(data, kernel);
        }
Пример #2
0
        private void SupportVectorMachine(List <Tuple <double[], double> > data)
        {
            Kernel kernel   = new LinearKernel();
            double n        = 0.0;
            double C        = 0.0;
            bool   nAndCSet = false;

            foreach (var item in netMLObject.Options)
            {
                if (item == "linearkernel")
                {
                    kernel = new LinearKernel();
                }
                else if (item == "gaussiankernel")
                {
                    kernel = new GaussianKernel(1.0);
                }
                else if (item == "polynomialkernel")
                {
                    kernel = new PolynomialKernel(1);
                }
                else if (item == "logitkernel")
                {
                    kernel = new LogitKernel();
                }
                else if (item == "tanhkernel")
                {
                    kernel = new TanhKernel();
                }
            }
            foreach (var value in netMLObject.DoubleValues)
            {
                if (value.Key == "n")
                {
                    n        = value.Value;
                    nAndCSet = true;
                }
                else if (value.Key == "c")
                {
                    C        = value.Value;
                    nAndCSet = true;
                }
            }
            if (nAndCSet)
            {
                classification = new SVMClassifier(data, kernel, n, C);
            }
            else
            {
                classification = new SVMClassifier(data, kernel);
            }
        }