Open() public method

Open an existing EGB file.
public Open ( ) : void
return void
Exemplo 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);
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Open the binary file for reading.
 /// </summary>
 public void Open()
 {
     _egb.Open();
 }
Exemplo n.º 5
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();
     }
 }
Exemplo n.º 6
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);
        }