示例#1
0
        public void Run(ISupervisedAlgorithm <double[]> algorithm, int xidx = 0, int yidx = 1, double[] shear = null)
        {
            m_XIdx     = xidx;
            m_YIdx     = yidx;
            m_Shear    = shear;
            m_InputDim = algorithm.TrainingSample.First().Key.Length;

            var fn = string.Format("data/{0}-{1:yyyyMMdd-hhmmss}.csv", algorithm.ID, DateTime.Now);

            using (var file = File.Create(fn))
                using (var writer = new StreamWriter(file))
                {
                    prepareCanvas();
                    doCalc(algorithm, writer);
                }
        }
示例#2
0
        private void doCalc(ISupervisedAlgorithm <double[]> algorithm, StreamWriter writer)
        {
            for (var k = 0; k < Math.Max(m_XCnt, m_YCnt); k++)
            {
                var px = (k < m_XCnt) ? getProjPoint(k, 0)[0].ToString() : string.Empty;
                var py = (k < m_YCnt) ? getProjPoint(0, k)[1].ToString() : string.Empty;
                var pd = string.Empty;
                if (k < m_YCnt)
                {
                    var data = new double[m_XCnt];
                    for (int i = 0; i < m_XCnt; i++)
                    {
                        var point = getPoint(i, k);
                        var cls   = algorithm.Classify(point);
                        data[i] = cls.Value;
                    }
                    pd = string.Join(COMMA, data);
                }

                writer.WriteLine("{0},{1},{2}", px, py, pd);
            }
        }