Ejemplo n.º 1
0
 /// <summary>
 /// Construct a buffered dataset using the specified file.
 /// </summary>
 /// <param name="binaryFile">The file to read/write binary data to/from.</param>
 public BufferedMLDataSet(String binaryFile)
 {
     _file = binaryFile;
     _egb  = new EncogEGBFile(binaryFile);
     if (File.Exists(_file))
     {
         _egb.Open();
     }
 }
        /// <summary>
        /// Convert an Encog binary file to an external form, such as CSV.
        /// </summary>
        /// <param name="binaryFile">THe binary file to use.</param>
        public void Binary2External(String binaryFile)
        {
            Status.Report(0, 0, "Exporting binary file: " + binaryFile);

            var egb = new EncogEGBFile(binaryFile);

            egb.Open();

            _codec.PrepareWrite(egb.NumberOfRecords, egb.InputCount,
                                egb.IdealCount);

            int inputCount = egb.InputCount;
            int idealCount = egb.IdealCount;

            var input = new double[inputCount];
            var ideal = new double[idealCount];

            int currentRecord = 0;
            int lastUpdate    = 0;

            // now load the data
            for (int i = 0; i < egb.NumberOfRecords; i++)
            {
                for (int j = 0; j < inputCount; j++)
                {
                    input[j] = egb.Read();
                }

                for (int j = 0; j < idealCount; j++)
                {
                    ideal[j] = egb.Read();
                }

                double significance = egb.Read();

                _codec.Write(input, ideal, significance);

                currentRecord++;
                lastUpdate++;
                if (lastUpdate >= 10000)
                {
                    lastUpdate = 0;
                    Status.Report(egb.NumberOfRecords, currentRecord,
                                  "Exporting...");
                }
            }

            egb.Close();
            _codec.Close();
            Status.Report(0, 0, "Done exporting binary file: "
                          + binaryFile);
        }
Ejemplo n.º 3
0
 public BufferedMLDataSet(string binaryFile)
 {
     if (0 == 0)
     {
         if (0 != 0)
         {
             return;
         }
         this.xb44380e048627945 = binaryFile;
     }
     this.xb77060c140f92cfd = new EncogEGBFile(binaryFile);
     if ((15 == 0) || File.Exists(this.xb44380e048627945))
     {
         this.xb77060c140f92cfd.Open();
     }
 }
Ejemplo n.º 4
0
 public override sealed bool ExecuteCommand(string args)
 {
     FileInfo info2;
     string str3;
     string str4;
     EncogEGBFile file;
     int inputCount;
     int num2;
     string propertyString = base.Prop.GetPropertyString("ML:CONFIG_trainingFile");
     if (0x7fffffff != 0)
     {
         FileInfo info;
         string sourceID = base.Prop.GetPropertyString("ML:CONFIG_machineLearningFile");
         if (((uint) num2) <= uint.MaxValue)
         {
             info = base.Script.ResolveFilename(propertyString);
             info2 = base.Script.ResolveFilename(sourceID);
         }
         str3 = base.Prop.GetPropertyString("ML:CONFIG_type");
         str4 = base.Prop.GetPropertyString("ML:CONFIG_architecture");
         EncogLogging.Log(0, "Beginning create");
         EncogLogging.Log(0, "training file:" + propertyString);
         EncogLogging.Log(0, "resource file:" + sourceID);
         EncogLogging.Log(0, "type:" + str3);
         EncogLogging.Log(0, "arch:" + str4);
         file = new EncogEGBFile(info.ToString());
         goto Label_00A6;
     }
     Label_002E:
     num2 = file.IdealCount;
     file.Close();
     IMLMethod method = new MLMethodFactory().Create(str3, str4, inputCount, num2);
     if ((((uint) inputCount) + ((uint) num2)) >= 0)
     {
         if (1 != 0)
         {
         }
         EncogDirectoryPersistence.SaveObject(info2, method);
         return false;
     }
     Label_00A6:
     file.Open();
     inputCount = file.InputCount;
     goto Label_002E;
 }
Ejemplo n.º 5
0
        /// <inheritdoc />
        public override sealed bool ExecuteCommand(String args)
        {
            // get filenames
            String trainingID = Prop.GetPropertyString(
                ScriptProperties.MlConfigTrainingFile);
            String resourceID = Prop.GetPropertyString(
                ScriptProperties.MlConfigMachineLearningFile);

            FileInfo trainingFile = Script.ResolveFilename(trainingID);
            FileInfo resourceFile = Script.ResolveFilename(resourceID);

            String type = Prop.GetPropertyString(
                ScriptProperties.MlConfigType);
            String arch = Prop.GetPropertyString(
                ScriptProperties.MlConfigArchitecture);

            EncogLogging.Log(EncogLogging.LevelDebug, "Beginning create");
            EncogLogging.Log(EncogLogging.LevelDebug, "training file:"
                                                      + trainingID);
            EncogLogging.Log(EncogLogging.LevelDebug, "resource file:"
                                                      + resourceID);
            EncogLogging.Log(EncogLogging.LevelDebug, "type:" + type);
            EncogLogging.Log(EncogLogging.LevelDebug, "arch:" + arch);

            var egb = new EncogEGBFile(trainingFile.ToString());
            egb.Open();
            int input = egb.InputCount;
            int ideal = egb.IdealCount;
            egb.Close();

            var factory = new MLMethodFactory();
            IMLMethod obj = factory.Create(type, arch, input, ideal);

            if (obj is BayesianNetwork)
            {
                string query = Prop.GetPropertyString(ScriptProperties.MLConfigQuery);
                ((BayesianNetwork) obj).DefineClassificationStructure(query);
            }

            EncogDirectoryPersistence.SaveObject(resourceFile, obj);

            return false;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Close the dataset.
        /// </summary>
        public void Close()
        {
            Object[] obj = _additional.ToArray();

            foreach (var set in obj.Cast <BufferedMLDataSet>())
            {
                set.Close();
            }

            _additional.Clear();

            if (_owner != null)
            {
                _owner.RemoveAdditional(this);
            }

            _egb.Close();
            _egb = null;
        }
        /// <summary>
        /// Convert an external file format, such as CSV, to the Encog binary
        /// training format.
        /// </summary>
        /// <param name="binaryFile">The binary file to create.</param>
        public void External2Binary(String binaryFile)
        {
            Status.Report(0, 0, "Importing to binary file: "
                          + binaryFile);

            var egb = new EncogEGBFile(binaryFile);

            egb.Create(_codec.InputSize, _codec.IdealSize);

            var input = new double[_codec.InputSize];
            var ideal = new double[_codec.IdealSize];

            _codec.PrepareRead();

            int    currentRecord = 0;
            int    lastUpdate    = 0;
            double significance  = 0;

            while (_codec.Read(input, ideal, ref significance))
            {
                egb.Write(input);
                egb.Write(ideal);

                currentRecord++;
                lastUpdate++;
                if (lastUpdate >= 10000)
                {
                    lastUpdate = 0;
                    Status.Report(0, currentRecord, "Importing...");
                }
                egb.Write(significance);
            }

            egb.Close();
            _codec.Close();
            Status.Report(0, 0, "Done importing to binary file: "
                          + binaryFile);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Convert an external file format, such as CSV, to the Encog binary
        /// training format. 
        /// </summary>
        /// <param name="binaryFile">The binary file to create.</param>
        public void External2Binary(String binaryFile)
        {
            Status.Report(0, 0, "Importing to binary file: "
                                + binaryFile);

            var egb = new EncogEGBFile(binaryFile);

            egb.Create(_codec.InputSize, _codec.IdealSize);

            var input = new double[_codec.InputSize];
            var ideal = new double[_codec.IdealSize];

            _codec.PrepareRead();

            int currentRecord = 0;
            int lastUpdate = 0;
            double significance = 0;

            while (_codec.Read(input, ideal, ref significance))
            {
                egb.Write(input);
                egb.Write(ideal);

                currentRecord++;
                lastUpdate++;
                if (lastUpdate >= 10000)
                {
                    lastUpdate = 0;
                    Status.Report(0, currentRecord, "Importing...");
                }
                egb.Write(significance);
            }

            egb.Close();
            _codec.Close();
            Status.Report(0, 0, "Done importing to binary file: "
                                + binaryFile);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Close the dataset.
        /// </summary>
        public void Close()
        {
            Object[] obj = _additional.ToArray();

            foreach (var set in obj.Cast<BufferedMLDataSet>())
            {
                set.Close();
            }

            _additional.Clear();

            if (_owner != null)
            {
                _owner.RemoveAdditional(this);
            }

            _egb.Close();
            _egb = null;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Construct a buffered dataset using the specified file. 
 /// </summary>
 /// <param name="binaryFile">The file to read/write binary data to/from.</param>
 public BufferedMLDataSet(String binaryFile)
 {
     _file = binaryFile;
     _egb = new EncogEGBFile(binaryFile);
     if (File.Exists(_file))
     {
         _egb.Open();
     }
 }
Ejemplo n.º 11
0
 public void Binary2External(string binaryFile)
 {
     EncogEGBFile file;
     int inputCount;
     int idealCount;
     double[] numArray;
     double[] numArray2;
     int num3;
     int num5;
     int num6;
     int num7;
     this.Status.Report(0, 0, "Exporting binary file: " + binaryFile);
     if (0 == 0)
     {
         file = new EncogEGBFile(binaryFile);
         goto Label_0283;
     }
     goto Label_0256;
     Label_008A:
     if (num5 < file.NumberOfRecords)
     {
         num6 = 0;
         if ((((uint) num3) - ((uint) idealCount)) >= 0)
         {
             goto Label_01BF;
         }
         goto Label_0210;
     }
     file.Close();
     this._x75d376891c19d365.Close();
     this.Status.Report(0, 0, "Done exporting binary file: " + binaryFile);
     return;
     Label_0105:
     if (num7 < idealCount)
     {
         goto Label_0142;
     }
     if ((((uint) num7) + ((uint) num5)) <= uint.MaxValue)
     {
         goto Label_016E;
     }
     Label_0122:
     num7 = 0;
     goto Label_0105;
     Label_0142:
     numArray2[num7] = file.Read();
     Label_014D:
     num7++;
     if ((((uint) num7) | 0xfffffffe) != 0)
     {
         if ((((uint) num6) + ((uint) num6)) > uint.MaxValue)
         {
             if ((((uint) num7) - ((uint) num3)) < 0)
             {
                 goto Label_0283;
             }
             goto Label_0142;
         }
         goto Label_0105;
     }
     Label_016E:
     if (((uint) num3) >= 0)
     {
         goto Label_0244;
     }
     if ((((uint) num5) | 2) != 0)
     {
         goto Label_01FD;
     }
     if (((uint) num7) >= 0)
     {
         goto Label_01C6;
     }
     Label_01BF:
     while (num6 < inputCount)
     {
         numArray[num6] = file.Read();
         num6++;
     }
     goto Label_0210;
     Label_01C6:
     if (((uint) idealCount) < 0)
     {
         goto Label_014D;
     }
     goto Label_008A;
     Label_01FD:
     numArray2 = new double[idealCount];
     num3 = 0;
     int num4 = 0;
     num5 = 0;
     goto Label_01C6;
     Label_0210:
     if ((((uint) num5) | 15) != 0)
     {
         goto Label_0122;
     }
     Label_0244:
     if (((uint) num7) <= uint.MaxValue)
     {
         double significance = file.Read();
         this._x75d376891c19d365.Write(numArray, numArray2, significance);
         num3++;
         if ((((uint) num5) | uint.MaxValue) == 0)
         {
             goto Label_01FD;
         }
         num4++;
         if (num4 >= 0x2710)
         {
             num4 = 0;
             if ((((uint) num4) + ((uint) num5)) < 0)
             {
                 goto Label_0142;
             }
             this.Status.Report(file.NumberOfRecords, num3, "Exporting...");
         }
         num5++;
         goto Label_008A;
     }
     Label_0256:
     this._x75d376891c19d365.PrepareWrite(file.NumberOfRecords, file.InputCount, file.IdealCount);
     inputCount = file.InputCount;
     idealCount = file.IdealCount;
     numArray = new double[inputCount];
     goto Label_01FD;
     Label_0283:
     file.Open();
     goto Label_0256;
 }
Ejemplo n.º 12
0
 public void External2Binary(string binaryFile)
 {
     EncogEGBFile file;
     double[] numArray;
     double[] numArray2;
     int num;
     int num2;
     double num3;
     this.Status.Report(0, 0, "Importing to binary file: " + binaryFile);
     goto Label_0106;
     Label_0038:
     file.Write(num3);
     Label_0040:
     if (this._x75d376891c19d365.Read(numArray, numArray2, ref num3))
     {
         file.Write(numArray);
         file.Write(numArray2);
         num++;
         num2++;
     }
     else
     {
         file.Close();
         this._x75d376891c19d365.Close();
         this.Status.Report(0, 0, "Done importing to binary file: " + binaryFile);
         return;
     }
     Label_0082:
     if (num2 >= 0x2710)
     {
         do
         {
             num2 = 0;
         }
         while (0 != 0);
         this.Status.Report(0, num, "Importing...");
         if (((uint) num) > uint.MaxValue)
         {
             goto Label_0082;
         }
     }
     else
     {
         goto Label_0038;
     }
     if ((((uint) num) + ((uint) num2)) > uint.MaxValue)
     {
         goto Label_010D;
     }
     goto Label_0038;
     Label_0106:
     file = new EncogEGBFile(binaryFile);
     Label_010D:
     file.Create(this._x75d376891c19d365.InputSize, this._x75d376891c19d365.IdealSize);
     numArray = new double[this._x75d376891c19d365.InputSize];
     numArray2 = new double[this._x75d376891c19d365.IdealSize];
     this._x75d376891c19d365.PrepareRead();
     num = 0;
     num2 = 0;
     if ((((uint) num2) + ((uint) num2)) >= 0)
     {
         num3 = 0.0;
         goto Label_0040;
     }
     goto Label_0106;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Convert an Encog binary file to an external form, such as CSV. 
        /// </summary>
        /// <param name="binaryFile">THe binary file to use.</param>
        public void Binary2External(String binaryFile)
        {
            Status.Report(0, 0, "Exporting binary file: " + binaryFile);

            var egb = new EncogEGBFile(binaryFile);
            egb.Open();

            _codec.PrepareWrite(egb.NumberOfRecords, egb.InputCount,
                               egb.IdealCount);

            int inputCount = egb.InputCount;
            int idealCount = egb.IdealCount;

            var input = new double[inputCount];
            var ideal = new double[idealCount];

            int currentRecord = 0;
            int lastUpdate = 0;

            // now load the data
            for (int i = 0; i < egb.NumberOfRecords; i++)
            {
                for (int j = 0; j < inputCount; j++)
                {
                    input[j] = egb.Read();
                }

                for (int j = 0; j < idealCount; j++)
                {
                    ideal[j] = egb.Read();
                }

                double significance = egb.Read();

                _codec.Write(input, ideal, significance);

                currentRecord++;
                lastUpdate++;
                if (lastUpdate >= 10000)
                {
                    lastUpdate = 0;
                    Status.Report(egb.NumberOfRecords, currentRecord,
                                  "Exporting...");
                }
            }

            egb.Close();
            _codec.Close();
            Status.Report(0, 0, "Done exporting binary file: "
                                + binaryFile);
        }
Ejemplo n.º 14
0
 public void Close()
 {
     object[] source = this.xaa0d3e5126463e13.ToArray<BufferedMLDataSet>();
     Label_0040:
     foreach (BufferedMLDataSet set in source.Cast<BufferedMLDataSet>())
     {
         set.Close();
     }
     this.xaa0d3e5126463e13.Clear();
     Label_002C:
     if (this._x071bde1041617fce != null)
     {
         this._x071bde1041617fce.RemoveAdditional(this);
         if (-2147483648 == 0)
         {
             goto Label_002C;
         }
         if (0 == 0)
         {
             if (-2147483648 == 0)
             {
                 return;
             }
         }
         else
         {
             goto Label_0040;
         }
     }
     this.xb77060c140f92cfd.Close();
     this.xb77060c140f92cfd = null;
     if (1 != 0)
     {
         return;
     }
     goto Label_0040;
 }