コード例 #1
0
ファイル: Optimizer.cs プロジェクト: IsaacSherman/Thesis
        /// <summary>
        /// This assumes that we are not using the dll interface, because we can get CV labels and save much more directly.
        /// </summary>
        /// <param name="doSave"></param>
        /// <param name="path"></param>
        public virtual void SaveModelByLongEval(bool doSave, string path)
        {
            Prepare();
            setFeatures();
            object[] args = getObjArgs();
            object   argsOut;

            OptoGlobals.CreateDirectoryAndThenFile(path);
            OptoGlobals.executor.Feval("longMCSave", 2, out argsOut, doSave, path, getFunctionString(),
                                       _nLearners, Util.TwoDimListToSmoothArray(myTrX), Util.TwoDimListToSmoothArray(myTeX),
                                       OptoGlobals.trainingYIntArray, OptoGlobals.testingYIntArray, myBaseLabels, args);

            object[] parsedArgsOut = (object[])argsOut;
            if (!Multiclass)
            {
                CVGeneratedLabels = ListFromColumnArray((int[, ])parsedArgsOut[0]);
                GeneratedLabels   = ListFromColumnArray((int[, ])parsedArgsOut[1]);
            }
            else
            {
                CVGeneratedLabels = ListFromColumnArray((int[, ])parsedArgsOut[0]);
                GeneratedLabels   = ListFromColumnArray((int[, ])parsedArgsOut[1]);
            }
            NullData();
        }
コード例 #2
0
 private void dumpPopulationToFile()
 {
     OptoGlobals.CreateDirectoryAndThenFile(_currentGenPath);
     using (StreamWriter fout = new StreamWriter(File.Create(_currentGenPath)))
     {
         foreach (Optimizer O in Population)
         {
             fout.WriteLine(O.ToString());
         }
     }
 }
コード例 #3
0
 public OptimoEvolver(int PopSize, CrossoverType xType, string fileStem, bool loadFromFile = false)
 {
     ReadInCurrentGeneration = loadFromFile;
     CountFeatures           = OptoGlobals.IsDebugMode;
     Console.WriteLine("Count Features is " + (CountFeatures ? "On" : "Off"));
     generation  = 0;
     _cross      = xType;
     _popSize    = PopSize;
     _population = new List <T>(_popSize);
     FileStem    = fileStem;
     for (int i = 0; i < _popSize; ++i)
     {
         _population.Add(new T());
     }
     _outputPath     = FileStem + "OutputTable.csv";
     _currentGenPath = FileStem + "/CurrentGenPop.csv";
     _lookup         = new Dictionary <string, Tuple <Double, Double> >();
     if (File.Exists(_outputPath))
     {
         readLookupFromFile();
     }
     else
     {
         OptoGlobals.CreateDirectoryAndThenFile(_outputPath);
     }
     if (FocusOnAllColumns)
     {
         SetPopToAllCols();
     }
     if (ReadInCurrentGeneration)
     {
         if (File.Exists(_currentGenPath))
         {
             loadPopulationFromFile();
         }
         else
         {
             dumpPopulationToFile();
         }
     }
 }