/// <summary> /// Read an individual record. /// </summary> /// <param name="index">The zero-based index. Specify 0 for the first record, 1 for /// the second, and so on.</param> /// <param name="pair">The data to read.</param> public void GetRecord(long index, IMLDataPair pair) { double[] inputTarget = pair.InputArray; double[] idealTarget = pair.IdealArray; egb.SetLocation((int)index); egb.Read(inputTarget); egb.Read(idealTarget); pair.Significance = egb.Read(); }
/// <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); }
/// <inheritdoc/> public IMLDataPair this[int x] { get { var input = new double[InputSize]; var ideal = new double[IdealSize]; _egb.SetLocation(x); _egb.Read(input); _egb.Read(ideal); var inputData = new BasicMLData(input, false); var idealData = new BasicMLData(ideal, false); var result = new BasicMLDataPair(inputData, idealData); result.Significance = _egb.Read(); return(result); } }
/// <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); }