Inheritance: IDataSetCODEC
        public void TestCSV()
        {
            var codec = new ArrayDataCODEC(XOR.XORInput, XOR.XORIdeal);
            var loader = new BinaryDataLoader(codec);
            loader.External2Binary("encog.bin");

            var codec2 = new CSVDataCODEC("encog.csv", CSVFormat.English, false);
            var loader2 = new BinaryDataLoader(codec2);
            loader2.Binary2External("encog.bin");

            var codec3 = new CSVDataCODEC("encog.csv", CSVFormat.English, false, 2, 1, false);
            var loader3 = new BinaryDataLoader(codec3);
            loader3.External2Binary("encog.bin");

            var codec4 = new ArrayDataCODEC();
            var loader4 = new BinaryDataLoader(codec4);
            loader4.Binary2External("encog.bin");

            double[][] input = codec4.Input;
            double[][] ideal = codec4.Ideal;

            for (int i = 0; i < XOR.XORInput.Length; i++)
            {
                for (int j = 0; j < XOR.XORInput[i].Length; j++)
                {
                    Assert.AreEqual(input[i][j], XOR.XORInput[i][j], 0.01);
                }

                for (int j = 0; j < XOR.XORIdeal[i].Length; j++)
                {
                    Assert.AreEqual(ideal[i][j], XOR.XORIdeal[i][j], 0.01);
                }
            }
        }
Ejemplo n.º 2
0
 public CSVMLDataSet(string filename, int inputSize, int idealSize, bool headers, CSVFormat format, bool expectSignificance)
 {
     this._xb41a802ca5fde63b = filename;
     this._x7e648b416c264559 = inputSize;
     if (-2 != 0)
     {
         this._x08b9e0820ab2b457 = idealSize;
     }
     this._x5786461d089b10a0 = format;
     this._x94e6ca5ac178dbd0 = headers;
     IDataSetCODEC codec = new CSVDataCODEC(filename, format, headers, inputSize, idealSize, expectSignificance);
     MemoryDataLoader loader2 = new MemoryDataLoader(codec) {
         Result = this
     };
     loader2.External2Memory();
 }
        /// <summary>
        /// Construct this data set using a comma as a delimiter.
        /// </summary>
        /// <param name="filename">The CSV filename to read.</param>
        /// <param name="inputSize">The number of columns that make up the input set.</param>
        /// <param name="idealSize">The number of columns that make up the ideal set.</param>
        /// <param name="headers">True if headers are present on the first line.</param>
        /// <param name="format">The format to use.</param>
        public CSVMLDataSet(String filename, int inputSize,
                            int idealSize, bool headers, CSVFormat format, bool expectSignificance)
        {
            _filename = filename;
            _inputSize = inputSize;
            _idealSize = idealSize;
            _format = format;
            _headers = headers;

            IDataSetCODEC codec = new CSVDataCODEC(filename, format, headers, inputSize, idealSize, expectSignificance);
            var load = new MemoryDataLoader(codec) {Result = this};
            load.External2Memory();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Load CSV to memory.
 /// </summary>
 /// <param name="filename">The CSV file to load.</param>
 /// <param name="input">The input count.</param>
 /// <param name="ideal">The ideal count.</param>
 /// <param name="headers">True, if headers are present.</param>
 /// <param name="format">The loaded dataset.</param>
 /// <param name="expectSignificance">The loaded dataset.</param>
 /// <returns></returns>
 public static IMLDataSet LoadCSV2Memory(String filename, int input, int ideal, bool headers, CSVFormat format, bool expectSignificance)
 {
     IDataSetCODEC codec = new CSVDataCODEC(filename, format, headers, input, ideal, expectSignificance);
     var load = new MemoryDataLoader(codec);
     IMLDataSet dataset = load.External2Memory();
     return dataset;
 }
Ejemplo n.º 5
0
        private void ConvertEGB2CSV()
        {
            if (_cmd.Args.Count != 2)
            {
                Console.WriteLine(@"Must specify a source and target.");
                return;
            }

            String sourceFile = _cmd.Args[0];
            String targetFile = _cmd.Args[1];

            AnalystFileFormat format1 =
                ConvertStringConst.String2AnalystFileFormat(_cmd.PromptString("format", "decpnt|comma"));
            CSVFormat format = ConvertStringConst.ConvertToCSVFormat(format1);

            new FileInfo(targetFile).Delete();
            IDataSetCODEC codec = new CSVDataCODEC(targetFile, format, false);
            var loader = new BinaryDataLoader(codec) {Status = new ConsoleStatusReportable()};
            _sw.Start();
            loader.Binary2External(sourceFile);
        }
Ejemplo n.º 6
0
        private void ConvertCSV2EGB()
        {
            if (_cmd.Args.Count != 2)
            {
                Console.WriteLine(@"Must specify a source and target.");
                return;
            }

            String sourceFile = _cmd.Args[0];
            String targetFile = _cmd.Args[1];
            bool headers = _cmd.PromptBoolean("headers", true);
            int inputCount = _cmd.PromptInteger("inputCount", 0);
            int outputCount = _cmd.PromptInteger("outputCount", 0);

            if (inputCount == 0)
            {
                Console.WriteLine(@"Must specify an input count.");
                return;
            }

            AnalystFileFormat format1 =
                ConvertStringConst.String2AnalystFileFormat(_cmd.PromptString("format", "decpnt|comma"));
            CSVFormat format = ConvertStringConst.ConvertToCSVFormat(format1);

            new FileInfo(targetFile).Delete();
            IDataSetCODEC codec = new CSVDataCODEC(sourceFile, format, headers,
                                                   inputCount, outputCount, false);
            var loader = new BinaryDataLoader(codec) {Status = new ConsoleStatusReportable()};
            _sw.Start();
            loader.External2Binary(targetFile);
        }