ExecuteTask() public method

Execute a task.
public ExecuteTask ( AnalystTask task ) : void
task Encog.App.Analyst.Script.Task.AnalystTask The task to execute.
return void
        public void TestRegression()
        {
            FileInfo rawFile    = TEMP_DIR.CreateFile("simple.csv");
            FileInfo egaFile    = TEMP_DIR.CreateFile("simple.ega");
            FileInfo outputFile = TEMP_DIR.CreateFile("simple_output.csv");

            FileUtil.CopyResource("Encog.Resources.simple.csv", rawFile);
            FileUtil.CopyResource("Encog.Resources.simple-r.ega", egaFile);

            EncogAnalyst analyst = new EncogAnalyst();

            analyst.Load(egaFile);

            analyst.ExecuteTask("task-full");

            ReadCSV csv = new ReadCSV(outputFile.ToString(), true, CSVFormat.English);

            while (csv.Next())
            {
                double diff = Math.Abs(csv.GetDouble(2) - csv.GetDouble(4));
                Assert.IsTrue(diff < 1.5);
            }

            Assert.AreEqual(4, analyst.Script.Fields.Length);
            Assert.AreEqual(3, analyst.Script.Fields[3].ClassMembers.Count);

            csv.Close();
        }
Beispiel #2
0
        public void TestRegression()
        {
            FileInfo rawFile = TEMP_DIR.CreateFile("simple.csv");
            FileInfo egaFile = TEMP_DIR.CreateFile("simple.ega");
            FileInfo outputFile = TEMP_DIR.CreateFile("simple_output.csv");

            FileUtil.CopyResource("Encog.Resources.simple.csv", rawFile);
            FileUtil.CopyResource("Encog.Resources.simple-r.ega", egaFile);

            EncogAnalyst analyst = new EncogAnalyst();
            analyst.Load(egaFile);

            analyst.ExecuteTask("task-full");

            ReadCSV csv = new ReadCSV(outputFile.ToString(), true, CSVFormat.English);
            while (csv.Next())
            {
                double diff = Math.Abs(csv.GetDouble(2) - csv.GetDouble(4));
                Assert.IsTrue(diff < 1.5);
            }

            Assert.AreEqual(4, analyst.Script.Fields.Length);
            Assert.AreEqual(3, analyst.Script.Fields[3].ClassMembers.Count);

            csv.Close();
        }
        public void TestClassification()
        {
            FileInfo rawFile = TEMP_DIR.CreateFile("simple.csv");
            FileInfo egaFile = TEMP_DIR.CreateFile("simple.ega");
            FileInfo outputFile = TEMP_DIR.CreateFile("simple_output.csv");

            FileUtil.CopyResource("Encog.Resources.simple.csv", rawFile);
            FileUtil.CopyResource("Encog.Resources.simple-c.ega", egaFile);

            EncogAnalyst analyst = new EncogAnalyst();
            analyst.AddAnalystListener(new ConsoleAnalystListener());
            analyst.Load(egaFile);

            analyst.ExecuteTask("task-full");

            ReadCSV csv = new ReadCSV(outputFile.ToString(), true, CSVFormat.English);
            while (csv.Next())
            {
                Assert.AreEqual(csv.Get(3), csv.Get(4));
            }

            Assert.AreEqual(4, analyst.Script.Fields.Length);
            Assert.AreEqual(3, analyst.Script.Fields[3].ClassMembers.Count);

            csv.Close();
        }
Beispiel #4
0
        public void TestClassification()
        {
            FileInfo rawFile    = TEMP_DIR.CreateFile("simple.csv");
            FileInfo egaFile    = TEMP_DIR.CreateFile("simple.ega");
            FileInfo outputFile = TEMP_DIR.CreateFile("simple_output.csv");

            FileUtil.CopyResource("Encog.Resources.simple.csv", rawFile);
            FileUtil.CopyResource("Encog.Resources.simple-c.ega", egaFile);

            EncogAnalyst analyst = new EncogAnalyst();

            analyst.AddAnalystListener(new ConsoleAnalystListener());
            analyst.Load(egaFile);

            analyst.ExecuteTask("task-full");

            ReadCSV csv = new ReadCSV(outputFile.ToString(), true, CSVFormat.English);

            while (csv.Next())
            {
                Assert.AreEqual(csv.Get(3), csv.Get(4));
            }

            Assert.AreEqual(4, analyst.Script.Fields.Length);
            Assert.AreEqual(3, analyst.Script.Fields[3].ClassMembers.Count);

            csv.Close();
        }
        public void TestWizard()
        {
            FileInfo rawFile = TEMP_DIR.CreateFile("iris_raw.csv");
            FileUtil.CopyResource("Encog.Resources.iris.csv", rawFile);

            FileInfo analystFile = TEMP_DIR.CreateFile("iris.ega");

            EncogAnalyst encog = new EncogAnalyst();
            AnalystWizard wiz = new AnalystWizard(encog);
            wiz.Goal = AnalystGoal.Classification;
            wiz.Wizard(rawFile, true, AnalystFileFormat.DecpntComma);


            encog.ExecuteTask("task-full");

            encog.Save(analystFile);
            encog.Load(analystFile);

            AnalystReport report = new AnalystReport(encog);
            report.ProduceReport(TEMP_DIR.CreateFile("report.html"));

            Assert.AreEqual(5, encog.Script.Normalize.NormalizedFields.Count);
            Assert.AreEqual(4.3, encog.Script.Fields[0].Min, 0.001);
            Assert.AreEqual(7.9, encog.Script.Fields[0].Max, 0.001);
            Assert.AreEqual(5.8483221477, encog.Script.Fields[0].Mean, 0.001);
            Assert.AreEqual(encog.Script.Fields[0].Class, false);
            Assert.AreEqual(encog.Script.Fields[0].Real, true);
            Assert.AreEqual(encog.Script.Fields[0].Integer, false);
            Assert.AreEqual(encog.Script.Fields[0].Complete, true);
            Assert.AreEqual(-3.38833, encog.Script.Normalize.NormalizedFields[0].Normalize(0.001), 0.001);
        }
        public void TestWizard()
        {
            FileInfo rawFile = TEMP_DIR.CreateFile("iris_raw.csv");

            FileUtil.CopyResource("Encog.Resources.iris.csv", rawFile);

            FileInfo analystFile = TEMP_DIR.CreateFile("iris.ega");

            EncogAnalyst  encog = new EncogAnalyst();
            AnalystWizard wiz   = new AnalystWizard(encog);

            wiz.Goal = AnalystGoal.Classification;
            wiz.Wizard(rawFile, true, AnalystFileFormat.DecpntComma);


            encog.ExecuteTask("task-full");

            encog.Save(analystFile);
            encog.Load(analystFile);

            AnalystReport report = new AnalystReport(encog);

            report.ProduceReport(TEMP_DIR.CreateFile("report.html"));

            Assert.AreEqual(5, encog.Script.Normalize.NormalizedFields.Count);
            Assert.AreEqual(4.3, encog.Script.Fields[0].Min, 0.001);
            Assert.AreEqual(7.9, encog.Script.Fields[0].Max, 0.001);
            Assert.AreEqual(5.84333, encog.Script.Fields[0].Mean, 0.001);
            Assert.AreEqual(encog.Script.Fields[0].Class, false);
            Assert.AreEqual(encog.Script.Fields[0].Real, true);
            Assert.AreEqual(encog.Script.Fields[0].Integer, false);
            Assert.AreEqual(encog.Script.Fields[0].Complete, true);
            Assert.AreEqual(-3.38833, encog.Script.Normalize.NormalizedFields[0].Normalize(0.001), 0.001);
        }
Beispiel #7
0
        public void Process(double maxError)
        {
            int    cycles = 0;
            double e;

            EncogAnalyst.AddAnalystListener(new ConsoleAnalystListener());

            do
            {
                EncogAnalyst.ExecuteTask("task-full");
                e = CalculateError();
                cycles++;
                Debug.WriteLine(cycles + ": Error = " + e);
            } while (cycles <= MaxCycles && e > maxError);

            Assert.IsTrue(cycles <= MaxCycles, "Too many cycles to perform successful train.");
        }
        public void IrisExample(FileInfo dir)
        {
            Console.WriteLine("Starting Iris dataset example.");
            Uri url = new Uri(IRIS_SOURCE);
            FileInfo analystFile = FileUtil.CombinePath(dir, "iris.ega");
            FileInfo rawFile = FileUtil.CombinePath(dir, "iris_raw.csv");

            EncogAnalyst encog = new EncogAnalyst();
            encog.AddAnalystListener(new ConsoleAnalystListener());
            AnalystWizard wiz = new AnalystWizard(encog);
            //wiz.TaskRandomize = false;
            wiz.Wizard(url, analystFile, rawFile, false, AnalystFileFormat.DecpntComma);
            encog.Save(analystFile);

            encog.ExecuteTask("task-full");

            

            AnalystReport report = new AnalystReport(encog);
            report.ProduceReport(FileUtil.CombinePath(dir, "report.html"));
        }
 public void ForestExample(FileInfo dir)
 {
     Console.WriteLine("Starting forest cover dataset example.");
     var url = new Uri(FOREST_SOURCE);
     FileInfo analystFile = FileUtil.CombinePath(dir, "forest.ega");
     FileInfo rawFile = FileUtil.CombinePath(dir, "forest_raw.csv");
     var encog = new EncogAnalyst();
     encog.AddAnalystListener(new ConsoleAnalystListener());
     var wiz = new AnalystWizard(encog);
     wiz.TaskBalance = true;
     wiz.Wizard(url, analystFile, rawFile, false, AnalystFileFormat.DecpntComma);
     encog.MaxIteration = 300;
     encog.ExecuteTask("task-full");
     encog.Save(analystFile);
     var report = new AnalystReport(encog);
     report.ProduceReport(FileUtil.CombinePath(dir, "report.html"));
 }
Beispiel #10
0
        private void AnalystCommand()
        {
            String egaFile;
            String task;

            if (_cmd.Args.Count == 0)
            {
                Console.WriteLine(@"Must specify the EGA file to run");
                return;
            }

            if (_cmd.Args.Count == 1)
            {
                egaFile = _cmd.Args[0];
                task = "task-full";
            }
            else
            {
                egaFile = _cmd.Args[0];
                task = _cmd.Args[1];
            }

            _sw.Start();
            var analyst = new EncogAnalyst();
            analyst.AddAnalystListener(new ConsoleAnalystListener());
            analyst.Load(new FileInfo(egaFile));
            analyst.ExecuteTask(task);
        }