コード例 #1
0
        public void TestIntegerBalance()
        {
            DataNormalization norm = CreateIntegerBalance();

            norm.Process();
            Check(norm, 3);
        }
コード例 #2
0
        public void TestRangeSegregate()
        {
            DataNormalization norm = CreateRangeSegregate();

            norm.Process();
            Check(norm, 1);
        }
コード例 #3
0
        public void TestIndexSegregate()
        {
            DataNormalization norm = CreateIndexSegregate();

            norm.Process();
            Check(norm, 6);
        }
コード例 #4
0
        private void Check(DataNormalization norm, int req)
        {
            ISegregator s = norm.Segregators[0];

            double[][] arrayOutput = ((NormalizationStorageArray2D)norm.Storage).GetArray();
            Assert.AreEqual(req, arrayOutput.Length);
        }
コード例 #5
0
        private void Generate()
        {
            IInputField a;
            IInputField b;
            IInputField c;
            IInputField d;
            IInputField e;

            var norm = new DataNormalization();

            norm.Report          = new NullStatusReportable();
            norm.Storage         = new NormalizationStorageCSV(FILENAME.ToString());
            norm.AddInputField(a = new InputFieldArray2D(false, ARRAY_2D, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, ARRAY_2D, 1));
            norm.AddInputField(c = new InputFieldArray2D(false, ARRAY_2D, 2));
            norm.AddInputField(d = new InputFieldArray2D(false, ARRAY_2D, 3));
            norm.AddInputField(e = new InputFieldArray2D(false, ARRAY_2D, 4));
            norm.AddOutputField(new OutputFieldDirect(a));
            norm.AddOutputField(new OutputFieldDirect(b));
            norm.AddOutputField(new OutputFieldDirect(c));
            norm.AddOutputField(new OutputFieldDirect(d));
            norm.AddOutputField(new OutputFieldDirect(e));
            norm.Storage = new NormalizationStorageCSV(FILENAME.ToString());
            norm.Process();
        }
コード例 #6
0
        public void TestSampleSegregate()
        {
            DataNormalization norm = CreateSampleSegregate();

            norm.Process();
            Check(norm, 6);
        }
コード例 #7
0
        public DataNormalization Create(double[][] outputArray)
        {
            IInputField a;
            IInputField b;
            IInputField c;
            IInputField d;
            IInputField e;

            var norm = new DataNormalization();

            norm.Report          = new NullStatusReportable();
            norm.Storage         = new NormalizationStorageCSV(FILENAME.ToString());
            norm.AddInputField(a = new InputFieldCSV(false, FILENAME.ToString(), 0));
            norm.AddInputField(b = new InputFieldCSV(false, FILENAME.ToString(), 1));
            norm.AddInputField(c = new InputFieldCSV(false, FILENAME.ToString(), 2));
            norm.AddInputField(d = new InputFieldCSV(false, FILENAME.ToString(), 3));
            norm.AddInputField(e = new InputFieldCSV(false, FILENAME.ToString(), 4));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(b, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(c, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(d, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(e, 0.1, 0.9));
            norm.Storage = new NormalizationStorageArray2D(outputArray);
            return(norm);
        }
コード例 #8
0
        public void TestAbsolute()
        {
            DataNormalization norm = Create();

            norm.Process();
            Check(norm);
        }
コード例 #9
0
 private void Check(DataNormalization norm)
 {
     double[][] arrayOutput = ((NormalizationStorageArray2D)norm.Storage).GetArray();
     Assert.AreEqual(arrayOutput[0][0], 0.1, 0.1);
     Assert.AreEqual(arrayOutput[1][0], 0.9, 0.1);
     Assert.AreEqual(arrayOutput[0][1], 0.1, 0.1);
     Assert.AreEqual(arrayOutput[1][1], 0.9, 0.1);
 }
コード例 #10
0
 private void Check(DataNormalization norm)
 {
     double[][] arrayOutput = ((NormalizationStorageArray2D) norm.Storage).GetArray();
     Assert.AreEqual(arrayOutput[0][0], 0.1, 0.1);
     Assert.AreEqual(arrayOutput[1][0], 0.9, 0.1);
     Assert.AreEqual(arrayOutput[0][1], 0.1, 0.1);
     Assert.AreEqual(arrayOutput[1][1], 0.9, 0.1);
 }
コード例 #11
0
        public void TestOutputFieldEncode()
        {
            double[][]        arrayOutput = EngineArray.AllocateDouble2D(2, 2);
            DataNormalization norm        = Create(arrayOutput);

            norm.Process();
            Check(arrayOutput);
        }
コード例 #12
0
        public void TestAbsoluteSerial()
        {
            DataNormalization norm = Create();

            norm = (DataNormalization)SerializeRoundTrip.RoundTrip(norm);
            norm.Process();
            Check(norm);
        }
コード例 #13
0
        public void TestArray2D()
        {
            double[][]        arrayOutput = EngineArray.AllocateDouble2D(2, 2);
            DataNormalization norm        = Create2D(arrayOutput);

            norm.Process();
            Check2D(arrayOutput);
        }
コード例 #14
0
        public void TestArray1D()
        {
            var arrayOutput        = new double[5];
            DataNormalization norm = Create1D(arrayOutput);

            norm.Process();
            Check1D(arrayOutput);
        }
コード例 #15
0
        public void TestGenerateAndLoad()
        {
            double[][] outputArray = EngineArray.AllocateDouble2D(2, 5);
            Generate();
            DataNormalization norm = Create(outputArray);

            norm.Process();
            Check(norm);
        }
コード例 #16
0
        public void TestArray2DSerial()
        {
            var arrayOutput        = EngineArray.AllocateDouble2D(2, 2);
            DataNormalization norm = Create2D(arrayOutput);

            norm        = (DataNormalization)SerializeRoundTrip.RoundTrip(norm);
            arrayOutput = ((NormalizationStorageArray2D)norm.Storage).GetArray();
            norm.Process();
            Check2D(arrayOutput);
        }
コード例 #17
0
        public void TestGenerateAndLoadSerial()
        {
            double[][] outputArray = EngineArray.AllocateDouble2D(2, 5);
            Generate(FILENAME2.ToString());
            DataNormalization norm = Create(FILENAME2.ToString(), outputArray);

            norm = (DataNormalization)SerializeRoundTrip.RoundTrip(norm);
            norm.Process();
            Check(norm);
        }
コード例 #18
0
        public void TestGenerateAndLoad()
        {
            var outputArray = EngineArray.AllocateDouble2D(2, 5);

            Generate(FILENAME1.ToString());
            DataNormalization norm = Create(FILENAME1.ToString(), outputArray);

            norm.Process();
            Check(norm);
        }
コード例 #19
0
        public void TestOutputFieldEncodeSerialize()
        {
            double[][]        arrayOutput = EngineArray.AllocateDouble2D(2, 2);
            DataNormalization norm        = Create(arrayOutput);

            norm        = (DataNormalization)SerializeRoundTrip.RoundTrip(norm);
            arrayOutput = ((NormalizationStorageArray2D)norm.Storage).GetArray();
            norm.Process();
            Check(arrayOutput);
        }
コード例 #20
0
        public void TestArray1DSerial()
        {
            var arrayOutput        = new double[5];
            DataNormalization norm = Create1D(arrayOutput);

            norm        = (DataNormalization)SerializeRoundTrip.RoundTrip(norm);
            arrayOutput = ((NormalizationStorageArray1D)norm.Storage).GetArray();
            norm.Process();
            Check1D(arrayOutput);
        }
コード例 #21
0
        public void TestAbsolute()
        {
            double[][]        arrayOutput = EngineArray.AllocateDouble2D(2, 3);
            DataNormalization norm        = Create(arrayOutput);

            norm.Process();
            for (int i = 0; i < arrayOutput[0].Length; i++)
            {
                Assert.AreEqual(arrayOutput[0][i], arrayOutput[1][i], 0.01);
            }
        }
コード例 #22
0
 public void BuildOutputOneOf(DataNormalization norm, IInputField coverType)
 {
     var outType = new OutputOneOf();
     outType.AddItem(coverType, 1);
     outType.AddItem(coverType, 2);
     outType.AddItem(coverType, 3);
     outType.AddItem(coverType, 4);
     outType.AddItem(coverType, 5);
     outType.AddItem(coverType, 6);
     outType.AddItem(coverType, 7);
     norm.AddOutputField(outType, true);
 }
コード例 #23
0
        public void TestAbsoluteSerial()
        {
            double[][]        arrayOutput = EngineArray.AllocateDouble2D(2, 3);
            DataNormalization norm        = Create(arrayOutput);

            norm        = (DataNormalization)SerializeRoundTrip.RoundTrip(norm);
            arrayOutput = ((NormalizationStorageArray2D)norm.Storage).GetArray();
            norm.Process();
            for (int i = 0; i < arrayOutput[0].Length; i++)
            {
                Assert.AreEqual(arrayOutput[0][i], arrayOutput[1][i], 0.01);
            }
        }
コード例 #24
0
        private void Check(DataNormalization norm)
        {
            double[][] arrayOutput = ((NormalizationStorageArray2D)norm.Storage).GetArray();

            Assert.AreEqual(-5.0, arrayOutput[0][0]);
            Assert.AreEqual(2.5, arrayOutput[0][1]);
            Assert.AreEqual(7.5, arrayOutput[0][2]);
            Assert.AreEqual(0.0, arrayOutput[0][3]);
            Assert.AreEqual(-1.0, arrayOutput[1][0]);
            Assert.AreEqual(0.5, arrayOutput[1][1]);
            Assert.AreEqual(1.5, arrayOutput[1][2]);
            Assert.AreEqual(0.0, arrayOutput[1][3]);
        }
コード例 #25
0
        private void Check(DataNormalization norm)
        {
            double[][] arrayOutput = ((NormalizationStorageArray2D) norm.Storage).GetArray();

            Assert.AreEqual(-5.0, arrayOutput[0][0]);
            Assert.AreEqual(2.5, arrayOutput[0][1]);
            Assert.AreEqual(7.5, arrayOutput[0][2]);
            Assert.AreEqual(0.0, arrayOutput[0][3]);
            Assert.AreEqual(-1.0, arrayOutput[1][0]);
            Assert.AreEqual(0.5, arrayOutput[1][1]);
            Assert.AreEqual(1.5, arrayOutput[1][2]);
            Assert.AreEqual(0.0, arrayOutput[1][3]);
        }
コード例 #26
0
        private DataNormalization Create1D(double[] arrayOutput)
        {
            IInputField a;

            var target = new NormalizationStorageArray1D(arrayOutput);

            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = target;
            norm.AddInputField(a = new InputFieldArray1D(false, ARRAY_1D));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            return norm;
        }
コード例 #27
0
        private DataNormalization Create1D(double[] arrayOutput)
        {
            IInputField a;

            var target = new NormalizationStorageArray1D(arrayOutput);

            var norm = new DataNormalization();

            norm.Report          = new NullStatusReportable();
            norm.Storage         = target;
            norm.AddInputField(a = new InputFieldArray1D(false, ARRAY_1D));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            return(norm);
        }
コード例 #28
0
        private void Check(DataNormalization norm)
        {
            IInputField a = norm.InputFields[0];
            IInputField b = norm.InputFields[1];

            Assert.AreEqual(1.0, a.Min, 0.1);
            Assert.AreEqual(6.0, a.Max, 0.1);
            Assert.AreEqual(2.0, b.Min, 0.1);
            Assert.AreEqual(7.0, b.Max, 0.1);

            double[][] outputArray = ((NormalizationStorageArray2D)norm.Storage).GetArray();
            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(0.1, outputArray[0][i], 0.1);
                Assert.AreEqual(0.9, outputArray[1][i], 0.1);
            }
        }
コード例 #29
0
        public DataNormalization CreateIndexSegregate()
        {
            IInputField a, b;
            double[][] arrayOutput = EngineArray.AllocateDouble2D(6, 2);

            var target = new NormalizationStorageArray2D(arrayOutput);

            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = target;
            norm.AddInputField(a = new InputFieldArray2D(false, ARRAY_2D, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, ARRAY_2D, 1));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(b, 0.1, 0.9));
            norm.AddSegregator(new IndexRangeSegregator(0, 3));
            return norm;
        }
コード例 #30
0
        private DataNormalization Create()
        {
            IInputField a, b;
            double[][] arrayOutput = EngineArray.AllocateDouble2D(2, 2);

            var dataset = new BasicMLDataSet(ARRAY_2D, null);

            var target = new NormalizationStorageArray2D(arrayOutput);

            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = target;
            norm.AddInputField(a = new InputFieldMLDataSet(false, dataset, 0));
            norm.AddInputField(b = new InputFieldMLDataSet(false, dataset, 1));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(b, 0.1, 0.9));
            return norm;
        }
コード例 #31
0
        private DataNormalization CreateSampleSegregate()
        {
            IInputField a, b;
            var         arrayOutput = EngineArray.AllocateDouble2D(6, 2);

            var target = new NormalizationStorageArray2D(arrayOutput);

            var norm = new DataNormalization();

            norm.Report          = new NullStatusReportable();
            norm.Storage         = target;
            norm.AddInputField(a = new InputFieldArray2D(false, ARRAY_2D, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, ARRAY_2D, 1));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(b, 0.1, 0.9));
            norm.AddSegregator(new IndexSampleSegregator(0, 3, 2));
            return(norm);
        }
コード例 #32
0
        public DataNormalization Create(double[][] arrayOutput)
        {
            IInputField a;
            IInputField b;
            IInputField c;

            var target = new NormalizationStorageArray2D(arrayOutput);
            var group = new MultiplicativeGroup();
            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = target;
            norm.AddInputField(a = new InputFieldArray2D(false, SAMPLE1, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, SAMPLE1, 1));
            norm.AddInputField(c = new InputFieldArray2D(false, SAMPLE1, 2));
            norm.AddOutputField(new OutputFieldMultiplicative(group, a));
            norm.AddOutputField(new OutputFieldMultiplicative(group, b));
            norm.AddOutputField(new OutputFieldMultiplicative(group, c));
            return norm;
        }
コード例 #33
0
        public void Copy(FileInfo source, FileInfo target, int start, int stop, int size)
        {
            var inputField = new IInputField[55];

            var norm = new DataNormalization {Report = this, Storage = new NormalizationStorageCSV(target.ToString())};
            for (int i = 0; i < 55; i++)
            {
                inputField[i] = new InputFieldCSV(true, source.ToString(), i);
                norm.AddInputField(inputField[i]);
                IOutputField outputField = new OutputFieldDirect(inputField[i]);
                norm.AddOutputField(outputField);
            }

            // load only the part we actually want, i.e. training or eval
            var segregator2 = new IndexSampleSegregator(start, stop, size);
            norm.AddSegregator(segregator2);

            norm.Process();
        }
コード例 #34
0
        public void Narrow(FileInfo source, FileInfo target, int field, int count)
        {
            var inputField = new IInputField[55];

            var norm = new DataNormalization {Report = this, Storage = new NormalizationStorageCSV(target.ToString())};
            for (int i = 0; i < 55; i++)
            {
                inputField[i] = new InputFieldCSV(true, source.ToString(), i);
                norm.AddInputField(inputField[i]);
                IOutputField outputField = new OutputFieldDirect(inputField[i]);
                norm.AddOutputField(outputField);
            }

            var segregator = new IntegerBalanceSegregator(inputField[field], count);
            norm.AddSegregator(segregator);

            norm.Process();
            Console.WriteLine(@"Samples per tree type:");
            Console.WriteLine(segregator.DumpCounts());
        }
コード例 #35
0
        private DataNormalization Create(double[][] arrayOutput)
        {
            IInputField a, b;

            var target = new NormalizationStorageArray2D(arrayOutput);
            OutputFieldEncode a1;
            OutputFieldEncode b1;

            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = target;
            norm.AddInputField(a = new InputFieldArray2D(false, ARRAY_2D, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, ARRAY_2D, 1));
            norm.AddOutputField(a1 = new OutputFieldEncode(a));
            norm.AddOutputField(b1 = new OutputFieldEncode(b));
            a1.AddRange(1.0, 2.0, 0.1);
            b1.AddRange(0, 100, 0.2);

            return norm;
        }
コード例 #36
0
        public DataNormalization Create(double[][] arrayOutput)
        {
            IInputField a;
            IInputField b;
            IInputField c;

            var target = new NormalizationStorageArray2D(arrayOutput);
            var group  = new MultiplicativeGroup();
            var norm   = new DataNormalization();

            norm.Report          = new NullStatusReportable();
            norm.Storage         = target;
            norm.AddInputField(a = new InputFieldArray2D(false, SAMPLE1, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, SAMPLE1, 1));
            norm.AddInputField(c = new InputFieldArray2D(false, SAMPLE1, 2));
            norm.AddOutputField(new OutputFieldMultiplicative(group, a));
            norm.AddOutputField(new OutputFieldMultiplicative(group, b));
            norm.AddOutputField(new OutputFieldMultiplicative(group, c));
            return(norm);
        }
コード例 #37
0
        private DataNormalization Create()
        {
            IInputField a, b;

            double[][] arrayOutput = EngineArray.AllocateDouble2D(2, 2);

            var dataset = new BasicMLDataSet(ARRAY_2D, null);

            var target = new NormalizationStorageArray2D(arrayOutput);

            var norm = new DataNormalization();

            norm.Report          = new NullStatusReportable();
            norm.Storage         = target;
            norm.AddInputField(a = new InputFieldMLDataSet(false, dataset, 0));
            norm.AddInputField(b = new InputFieldMLDataSet(false, dataset, 1));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(b, 0.1, 0.9));
            return(norm);
        }
コード例 #38
0
        public DataNormalization Create()
        {
            IInputField a;
            IInputField b;
            IInputField c;
            double[][] arrayOutput = EngineArray.AllocateDouble2D(2, 4);

            var target = new NormalizationStorageArray2D(arrayOutput);
            var group = new ZAxisGroup();
            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = target;
            norm.AddInputField(a = new InputFieldArray2D(false, SAMPLE1, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, SAMPLE1, 1));
            norm.AddInputField(c = new InputFieldArray2D(false, SAMPLE1, 2));
            norm.AddOutputField(new OutputFieldZAxis(group, a));
            norm.AddOutputField(new OutputFieldZAxis(group, b));
            norm.AddOutputField(new OutputFieldZAxis(group, c));
            norm.AddOutputField(new OutputFieldZAxisSynthetic(group));
            return norm;
        }
コード例 #39
0
        private DataNormalization Create(double[][] arrayOutput)
        {
            IInputField a, b;


            var target = new NormalizationStorageArray2D(arrayOutput);
            OutputFieldEncode a1;
            OutputFieldEncode b1;

            var norm = new DataNormalization();

            norm.Report            = new NullStatusReportable();
            norm.Storage           = target;
            norm.AddInputField(a   = new InputFieldArray2D(false, ARRAY_2D, 0));
            norm.AddInputField(b   = new InputFieldArray2D(false, ARRAY_2D, 1));
            norm.AddOutputField(a1 = new OutputFieldEncode(a));
            norm.AddOutputField(b1 = new OutputFieldEncode(b));
            a1.AddRange(1.0, 2.0, 0.1);
            b1.AddRange(0, 100, 0.2);

            return(norm);
        }
コード例 #40
0
        private DataNormalization CreateRangeSegregate()
        {
            IInputField a, b;

            double[][] arrayOutput = EngineArray.AllocateDouble2D(1, 2);

            RangeSegregator s;

            var target = new NormalizationStorageArray2D(arrayOutput);

            var norm = new DataNormalization();

            norm.Report          = new NullStatusReportable();
            norm.Storage         = target;
            norm.AddInputField(a = new InputFieldArray2D(false, ARRAY_2D, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, ARRAY_2D, 1));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(b, 0.1, 0.9));
            norm.AddSegregator(s = new RangeSegregator(a, false));
            s.AddRange(2, 2, true);
            return(norm);
        }
コード例 #41
0
        public DataNormalization Create()
        {
            IInputField a;
            IInputField b;
            IInputField c;

            double[][] arrayOutput = EngineArray.AllocateDouble2D(2, 4);

            var target = new NormalizationStorageArray2D(arrayOutput);
            var group  = new ZAxisGroup();
            var norm   = new DataNormalization();

            norm.Report          = new NullStatusReportable();
            norm.Storage         = target;
            norm.AddInputField(a = new InputFieldArray2D(false, SAMPLE1, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, SAMPLE1, 1));
            norm.AddInputField(c = new InputFieldArray2D(false, SAMPLE1, 2));
            norm.AddOutputField(new OutputFieldZAxis(group, a));
            norm.AddOutputField(new OutputFieldZAxis(group, b));
            norm.AddOutputField(new OutputFieldZAxis(group, c));
            norm.AddOutputField(new OutputFieldZAxisSynthetic(group));
            return(norm);
        }
コード例 #42
0
        private void Generate()
        {
            IInputField a;
            IInputField b;
            IInputField c;
            IInputField d;
            IInputField e;

            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = new NormalizationStorageCSV(FILENAME.ToString());
            norm.AddInputField(a = new InputFieldArray2D(false, ARRAY_2D, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, ARRAY_2D, 1));
            norm.AddInputField(c = new InputFieldArray2D(false, ARRAY_2D, 2));
            norm.AddInputField(d = new InputFieldArray2D(false, ARRAY_2D, 3));
            norm.AddInputField(e = new InputFieldArray2D(false, ARRAY_2D, 4));
            norm.AddOutputField(new OutputFieldDirect(a));
            norm.AddOutputField(new OutputFieldDirect(b));
            norm.AddOutputField(new OutputFieldDirect(c));
            norm.AddOutputField(new OutputFieldDirect(d));
            norm.AddOutputField(new OutputFieldDirect(e));
            norm.Storage = new NormalizationStorageCSV(FILENAME.ToString());
            norm.Process();
        }
コード例 #43
0
        public DataNormalization Create(string filename, double[][] outputArray)
        {
            IInputField a;
            IInputField b;
            IInputField c;
            IInputField d;
            IInputField e;

            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = new NormalizationStorageCSV(filename.ToString());
            norm.AddInputField(a = new InputFieldCSV(false, filename.ToString(), 0));
            norm.AddInputField(b = new InputFieldCSV(false, filename.ToString(), 1));
            norm.AddInputField(c = new InputFieldCSV(false, filename.ToString(), 2));
            norm.AddInputField(d = new InputFieldCSV(false, filename.ToString(), 3));
            norm.AddInputField(e = new InputFieldCSV(false, filename.ToString(), 4));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(b, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(c, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(d, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(e, 0.1, 0.9));
            norm.Storage = new NormalizationStorageArray2D(outputArray);
            return norm;
        }
コード例 #44
0
 private void Check(DataNormalization norm, int req)
 {
     ISegregator s = norm.Segregators[0];
     double[][] arrayOutput = ((NormalizationStorageArray2D) norm.Storage).GetArray();
     Assert.AreEqual(req, arrayOutput.Length);
 }
コード例 #45
0
ファイル: IndexSegregator.cs プロジェクト: neismit/emds
 public void Init(DataNormalization normalization)
 {
     this._normalization = normalization;
 }
コード例 #46
0
        private void Check(DataNormalization norm)
        {
            IInputField a = norm.InputFields[0];
            IInputField b = norm.InputFields[1];

            Assert.AreEqual(1.0, a.Min, 0.1);
            Assert.AreEqual(6.0, a.Max, 0.1);
            Assert.AreEqual(2.0, b.Min, 0.1);
            Assert.AreEqual(7.0, b.Max, 0.1);

            double[][] outputArray = ((NormalizationStorageArray2D) norm.Storage).GetArray();
            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(0.1, outputArray[0][i], 0.1);
                Assert.AreEqual(0.9, outputArray[1][i], 0.1);
            }
        }
コード例 #47
0
ファイル: NetworkUtility.cs プロジェクト: jongh0/MTree
 /// <summary>
 ///     Saves a normalization to the specified folder with the specified name.
 /// </summary>
 /// <param name="directory">The directory.</param>
 /// <param name="file">The file.</param>
 /// <param name="normTosave">The norm tosave.</param>
 public static void SaveNormalization(string directory, string file, DataNormalization normTosave)
 {
     SerializeObject.Save(directory + file, normTosave);
 }
コード例 #48
0
        private DataNormalization CreateRangeSegregate()
        {
            IInputField a, b;
            double[][] arrayOutput = EngineArray.AllocateDouble2D(1, 2);

            RangeSegregator s;

            var target = new NormalizationStorageArray2D(arrayOutput);

            var norm = new DataNormalization();
            norm.Report = new NullStatusReportable();
            norm.Storage = target;
            norm.AddInputField(a = new InputFieldArray2D(false, ARRAY_2D, 0));
            norm.AddInputField(b = new InputFieldArray2D(false, ARRAY_2D, 1));
            norm.AddOutputField(new OutputFieldRangeMapped(a, 0.1, 0.9));
            norm.AddOutputField(new OutputFieldRangeMapped(b, 0.1, 0.9));
            norm.AddSegregator(s = new RangeSegregator(a, false));
            s.AddRange(2, 2, true);
            return norm;
        }
コード例 #49
0
        public DataNormalization Step3(bool useOneOf)
        {
            Console.WriteLine(@"Step 3: Normalize training data");
            IInputField inputElevation;
            IInputField inputAspect;
            IInputField inputSlope;
            IInputField hWater;
            IInputField vWater;
            IInputField roadway;
            IInputField shade9;
            IInputField shade12;
            IInputField shade3;
            IInputField firepoint;
            var wilderness = new IInputField[4];
            var soilType = new IInputField[40];
            IInputField coverType;

            var norm = new DataNormalization
                           {
                               Report = this,
                               Storage = new NormalizationStorageCSV(_config.NormalizedDataFile.ToString())
                           };
            norm.AddInputField(inputElevation = new InputFieldCSV(true, _config.BalanceFile.ToString(), 0));
            norm.AddInputField(inputAspect = new InputFieldCSV(true, _config.BalanceFile.ToString(), 1));
            norm.AddInputField(inputSlope = new InputFieldCSV(true, _config.BalanceFile.ToString(), 2));
            norm.AddInputField(hWater = new InputFieldCSV(true, _config.BalanceFile.ToString(), 3));
            norm.AddInputField(vWater = new InputFieldCSV(true, _config.BalanceFile.ToString(), 4));
            norm.AddInputField(roadway = new InputFieldCSV(true, _config.BalanceFile.ToString(), 5));
            norm.AddInputField(shade9 = new InputFieldCSV(true, _config.BalanceFile.ToString(), 6));
            norm.AddInputField(shade12 = new InputFieldCSV(true, _config.BalanceFile.ToString(), 7));
            norm.AddInputField(shade3 = new InputFieldCSV(true, _config.BalanceFile.ToString(), 8));
            norm.AddInputField(firepoint = new InputFieldCSV(true, _config.BalanceFile.ToString(), 9));

            for (int i = 0; i < 4; i++)
            {
                norm.AddInputField(wilderness[i] = new InputFieldCSV(true, _config.BalanceFile.ToString(), 10 + i));
            }

            for (int i = 0; i < 40; i++)
            {
                norm.AddInputField(soilType[i] = new InputFieldCSV(true, _config.BalanceFile.ToString(), 14 + i));
            }

            norm.AddInputField(coverType = new InputFieldCSV(false, _config.BalanceFile.ToString(), 54));

            norm.AddOutputField(new OutputFieldRangeMapped(inputElevation));
            norm.AddOutputField(new OutputFieldRangeMapped(inputAspect));
            norm.AddOutputField(new OutputFieldRangeMapped(inputSlope));
            norm.AddOutputField(new OutputFieldRangeMapped(hWater));
            norm.AddOutputField(new OutputFieldRangeMapped(vWater));
            norm.AddOutputField(new OutputFieldRangeMapped(roadway));
            norm.AddOutputField(new OutputFieldRangeMapped(shade9));
            norm.AddOutputField(new OutputFieldRangeMapped(shade12));
            norm.AddOutputField(new OutputFieldRangeMapped(shade3));
            norm.AddOutputField(new OutputFieldRangeMapped(firepoint));

            for (int i = 0; i < 40; i++)
            {
                norm.AddOutputField(new OutputFieldDirect(soilType[i]));
            }

            if (useOneOf)
                BuildOutputOneOf(norm, coverType);
            else
                BuildOutputEquilateral(norm, coverType);

            norm.Process();
            return norm;
        }