Пример #1
0
        static void LaunchEOSVR(int popSize, int iterMax)
        {
            if (Equals(DataSet, null) || Equals(df, null))
            {
                return;
            }
            EOSVR eo_svr = new EOSVR(df.TrainingInput, df.TrainingOutput, df.TestingInput, df.TestingOutput);

            eo_svr.PopulationSize = popSize;
            eo_svr.MaxIterations  = iterMax;

            eo_svr.Sigma_Kernel     = 1.1;
            eo_svr.Param_Complexity = 100;
            eo_svr.Param_Epsilon    = 0.001;
            eo_svr.Param_Tolerance  = 0.001;

            Console.WriteLine("---------> SVR : ");
            eo_svr.Learn();

            //Console.WriteLine("---------> EO-SVR : ");
            //eo_svr.LearnEO();

            Console.WriteLine("Best score = {0}", eo_svr.BestScore);
            Console.WriteLine("Best learning index = {0} ; Best testing index = {1}", eo_svr.BestLearningScore, eo_svr.BestTestingScore);
        }
Пример #2
0
        static void SaveResults(EOSVR eo_svr, string filePath)
        {
            if (Equals(eo_svr, null))
            {
                return;
            }
            if (Equals(eo_svr.BestChart, null))
            {
                return;
            }
            if (Equals(eo_svr.BestSolution, null))
            {
                return;
            }

            using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate))
            {
                using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
                {
                    System.Text.StringBuilder strb = new System.Text.StringBuilder();

                    strb.AppendLine("Best_Chart;");

                    for (int i = 0; i < eo_svr.BestChart.Count(); i++)
                    {
                        strb.Append(eo_svr.BestChart[i].ToString()).AppendLine(";");
                    }

                    strb.AppendLine("Best Learning score;");
                    strb.Append(eo_svr.BestLearningScore).AppendLine(";");

                    strb.AppendLine("Best Testing Score;");
                    strb.Append(eo_svr.BestTestingScore).AppendLine(";");

                    strb.AppendLine("Best solution;");

                    for (int i = 0; i < eo_svr.BestSolution.Length; i++)
                    {
                        strb.Append(eo_svr.BestSolution[i]).AppendLine(";");
                    }

                    sw.Write(strb.ToString());
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                }
            }
        }
Пример #3
0
        static void LaunchEOSVR(int popSize, int iterMax)
        {
            if (Equals(DataSet, null) || Equals(df, null))
            {
                return;
            }
            EOSVR eo_svr = new EOSVR(df.TrainingInput, df.TrainingOutput, df.TestingInput, df.TestingOutput);

            eo_svr.PopulationSize = popSize;
            eo_svr.MaxIterations  = iterMax;

            eo_svr.Sigma_Kernel     = 1.1;   //1.1; //1.336687063023768
            eo_svr.Param_Complexity = 100;   // 100; //56.8121658157614
            eo_svr.Param_Epsilon    = 0.001; // 0.001
            eo_svr.Param_Tolerance  = 0.001; // 0.001

            // Console.WriteLine("---------> SVR : ");
            //eo_svr.Learn();

            Console.WriteLine("---------> EO-SVR : ");

            eo_svr.LearnEO();

            Console.WriteLine("Best score = {0}", eo_svr.BestScore);
            if (!Equals(eo_svr.BestSolution, null))
            {
                Console.WriteLine("Best solution : Sigma of Gaussian = {0}; Complexity = {1}; Tolerance = {2}; Epsilon = {3}.", eo_svr.BestSolution[0], eo_svr.BestSolution[1], eo_svr.BestSolution[2], eo_svr.BestSolution[3]);
            }
            // Console.WriteLine("Best soltion : SigmaKernel= {0}; Complexity_C= {1}; Tolerance= {2}; Epsilon= {3}", eo_svr.BestSolution[0],eo_svr.BestSolution[1],eo_svr.BestSolution[2],eo_svr.BestSolution[3]);

            Console.WriteLine("EO-SVR :->Best learning index = {0} ; EO-SVR :-> Best testing index = {1}", eo_svr.BestLearningScore, eo_svr.BestTestingScore);

            if (!Equals(eo_svr.BestChart, null))
            {
                foreach (var valu in eo_svr.BestChart)
                {
                    Console.WriteLine(valu);
                }
            }



            SaveResults(eo_svr, string.Format("C:\\SSL\\Results_SVR_{0}.txt", fileName.Trim()));

            //double[][] xy = new double[][]
            //{
            //   new double []{ 0.8},
            //   new double []{0.16},
            //   new double []{0.24},
            //   new double []{0.35},
            //   new double []{0.25}
            //};

            //var z = eo_svr.Compute(xy);

            //if (Equals(z, null)) { return; }
            //foreach (double value in z)
            //{
            //    Console.WriteLine("z = {0}", Math.Round( value,3));
            //}
        }