Esempio n. 1
0
        public string generateNNGraph(string matrixRef, int NumberInputsNodes, int NumberHiddenNodes, int NumberOutputNodes,
                                      int NumberOfEpochs, double LearningRate_eta, string title, int oneCol, string oneLab, int twoCol, string twoLab, string fileName)
        {
            var matrixComp = Value(matrixRef);

            if (matrixComp.GetType() == typeof(string))
            {
                return("Could not find variable " + matrixRef);
            }
            MatrixData _graphData = (MatrixData)matrixComp;

            double[] x  = _graphData.GetColumnCopy <double>(0);
            double[] y  = _graphData.GetColumnCopy <double>(1);
            double[] y1 = _graphData.GetColumnCopy <double>(2);

            double xMax = _graphData.Max(0);

            var plot = new PLStream();

            plot.width(1);
            plot.sdev("svg");
            plot.sfnam(fileName + ".svg");
            plot.scolbg(255, 255, 255);
            plot.init();

            plot.env(0, xMax, 0, 105, AxesScale.Independent, AxisBox.BoxTicksLabelsAxes);

            Dictionary <int, string> cols = new Dictionary <int, string>();

            cols.Add(0, "black");
            cols.Add(1, "red");
            cols.Add(2, "yellow");
            cols.Add(3, "green");
            cols.Add(4, "aquamarine");
            cols.Add(5, "pink");
            cols.Add(6, "wheat");
            cols.Add(7, "grey");
            cols.Add(8, "brown");
            cols.Add(9, "blue");
            cols.Add(10, "BlueViolet");
            cols.Add(11, "cyan");
            cols.Add(12, "turquoise");
            cols.Add(13, "magenta");
            cols.Add(14, "salmon");
            cols.Add(15, "white");


            plot.col0(1);
            plot.lab("Epoch", "Accuracy %", title);
            plot.ptex(xMax - 10, 25, 1.0, 0, 1, "Input Nodes: " + NumberInputsNodes);
            plot.ptex(xMax - 10, 20, 1.0, 0, 1, "Hidden Nodes: " + NumberHiddenNodes);
            plot.ptex(xMax - 10, 15, 1.0, 0, 1, "Output Nodes: " + NumberOutputNodes);
            plot.ptex(xMax - 10, 10, 1.0, 0, 1, "Epochs: " + NumberOfEpochs);
            plot.ptex(xMax - 10, 5, 1.0, 0, 1, "Learning Rate: " + LearningRate_eta);
            plot.col0(1);

            plot.col0(oneCol);
            plot.line(x, y);
            plot.ptex(xMax - 10, 35, 1.0, 0, 1, cols[oneCol] + ": " + oneLab);
            plot.col0(oneCol);

            plot.col0(twoCol);
            plot.line(x, y1);
            plot.ptex(xMax - 10, 30, 1.0, 0, 1, cols[twoCol] + ": " + twoLab);
            plot.col0(twoCol);

            plot.eop();

            return(Directory.GetCurrentDirectory() + "\\" + fileName + ".svg");
        }
Esempio n. 2
0
        public string GenerateGraph()
        {
            double[] x  = _graphData.GetColumnCopy <double>(0);
            double[] y  = _graphData.GetColumnCopy <double>(1);
            double[] y1 = _graphData.GetColumnCopy <double>(2);

            double xMax = _graphData.Max(0);
            //double yMax = _graphData.Max(1);
            //yMax = (_graphData.Max(2) > yMax)? _graphData.Max(2) : yMax;
            //double yMin = _graphData.Min(1);
            //yMin = (_graphData.Min(2) < yMin)? _graphData.Min(2): yMin;

            var plot = new PLStream();

            plot.width(1);
            plot.sdev("svg");
            plot.sfnam("Test.svg");
            plot.scolbg(255, 255, 255);
            plot.init();

            plot.env(0, xMax, 0, 105, AxesScale.Independent, AxisBox.BoxTicksLabelsAxes);

            //####### PLPlot colour guide:
            //0	black (default background)
            //1	red (default foreground)
            //2	yellow
            //3	green
            //4	aquamarine
            //5	pink
            //6	wheat
            //7	grey
            //8	brown
            //9	blue
            //10 BlueViolet
            //11 cyan
            //12 turquoise
            //13 magenta
            //14 salmon
            //15 white


            plot.col0(1);
            if (!(_testingData == null))
            {
                plot.lab("Epoch", "Accuracy %", "Test vs Train Accuracy");
            }
            else
            {
                plot.lab("Epoch", "Accuracy %", "Test vs Val Accuracy");
            }
            plot.ptex(xMax - 10, 25, 1.0, 0, 1, "Input Nodes: " + NumberInputsNodes);
            plot.ptex(xMax - 10, 20, 1.0, 0, 1, "Hidden Nodes: " + NumberHiddenNodes);
            plot.ptex(xMax - 10, 15, 1.0, 0, 1, "Output Nodes: " + NumberOutputNodes);
            plot.ptex(xMax - 10, 10, 1.0, 0, 1, "Epochs: " + NumberOfEpochs);
            plot.ptex(xMax - 10, 5, 1.0, 0, 1, "Learning Rate: " + LearningRate_eta);
            plot.col0(1);

            plot.col0(9);
            plot.line(x, y);
            plot.ptex(xMax - 10, 35, 1.0, 0, 1, "Blue: Train");
            plot.col0(9);

            plot.col0(3);
            plot.line(x, y1);
            if (!(_testingData == null))
            {
                plot.ptex(xMax - 10, 30, 1.0, 0, 1, "Green: Test");
            }
            else
            {
                plot.ptex(xMax - 10, 30, 1.0, 0, 1, "Green: Val");
            }
            plot.col0(3);

            plot.eop();

            return("Saved \"Test.svg\"");
        }