Ejemplo n.º 1
0
        static double test()
        {
            Console.WriteLine("reading test data...");
            Global.swLog.WriteLine("reading test data...");
            dataSet XX = new dataSet(Global.fFeatureTest, Global.fGoldTest);

            Console.WriteLine("Done! test data size: {0}", XX.Count);
            Global.swLog.WriteLine("Done! test data size: {0}", XX.Count);
            //load model & feature files for testing
            toolbox tb = new toolbox(XX, false);

            Stopwatch timer = new Stopwatch();

            timer.Start();

            List <double> scoreList = tb.test(XX, 0);

            timer.Stop();
            double time = timer.ElapsedMilliseconds / 1000.0;

            Global.timeList.Add(time);
            double score = scoreList[0];

            Global.scoreListList.Add(scoreList);

            resSummarize.write();
            return(score);
        }
Ejemplo n.º 2
0
        //this function can be called by train(), cv(), & richEdge.train()
        public static double baseTrain(dataSet XTest, toolbox tb)
        {
            Global.reinitGlobal();
            double score = 0;

            for (int i = 0; i < Global.ttlIter; i++)
            {
                Global.glbIter++;
                Stopwatch timer = new Stopwatch();
                timer.Start();

                double err = tb.train();

                timer.Stop();
                double time = timer.ElapsedMilliseconds / 1000.0;

                Global.timeList.Add(time);
                Global.errList.Add(err);
                Global.diffList.Add(Global.diff);

                List <double> scoreList = tb.test(XTest, i);
                score = scoreList[0];
                Global.scoreListList.Add(scoreList);

                Global.swLog.WriteLine("iter{0}  diff={1}  train-time(sec)={2}  {3}={4}%", Global.glbIter, Global.diff.ToString("e2"), time.ToString("f2"), Global.metric, score.ToString("f2"));
                Global.swLog.WriteLine("------------------------------------------------");
                Global.swLog.Flush();
                Console.WriteLine("iter{0}  diff={1}  train-time(sec)={2}  {3}={4}%", Global.glbIter, Global.diff.ToString("e2"), time.ToString("f2"), Global.metric, score.ToString("f2"));

                //if (Global.diff < Global.convergeTol)
                //break;
            }
            return(score);
        }