Ejemplo n.º 1
0
        private void ReOrderToIndices <T>(int columnIndex, int[] indices)
        {
            var originalData = new List <T>(PreprocessingData.GetValues <T>(columnIndex));

            if (indices.Length != originalData.Count)
            {
                throw new InvalidOperationException("The number of provided indices does not match the values.");
            }

            for (int i = 0; i < indices.Length; i++)
            {
                T newValue = originalData[indices[i]];
                PreprocessingData.SetCell <T>(columnIndex, i, newValue);
            }
        }
        public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameColor = "-")
        {
            ScatterPlot scatterPlot = new ScatterPlot();

            IList <double> xValues = PreprocessingData.GetValues <double>(PreprocessingData.GetColumnIndex(variableNameX));
            IList <double> yValues = PreprocessingData.GetValues <double>(PreprocessingData.GetColumnIndex(variableNameY));

            if (variableNameColor == null || variableNameColor == "-")
            {
                List <Point2D <double> > points = new List <Point2D <double> >();

                for (int i = 0; i < xValues.Count; i++)
                {
                    Point2D <double> point = new Point2D <double>(xValues[i], yValues[i]);
                    points.Add(point);
                }

                ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points);
                scatterPlot.Rows.Add(scdr);
            }
            else
            {
                var colorValues = PreprocessingData.GetValues <double>(PreprocessingData.GetColumnIndex(variableNameColor));
                var data        = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(colorValues, (v, c) => new { v.x, v.y, c }).ToList();
                var gradients   = ColorGradient.Colors;
                int curGradient = 0;
                int numColors   = colorValues.Distinct().Count();
                foreach (var colorValue in colorValues.Distinct())
                {
                    var values = data.Where(x => x.c == colorValue);
                    var row    = new ScatterPlotDataRow(
                        variableNameX + " - " + variableNameY + " (" + colorValue + ")",
                        "",
                        values.Select(v => new Point2D <double>(v.x, v.y)),
                        new ScatterPlotDataRowVisualProperties()
                    {
                        Color = gradients[curGradient]
                    });
                    curGradient += gradients.Count / numColors;
                    scatterPlot.Rows.Add(row);
                }
            }
            return(scatterPlot);
        }
Ejemplo n.º 3
0
        public IEnumerable <string> GetVariableNamesForHistogramClassification()
        {
            List <string> doubleVariableNames = new List <string>();

            //only return variable names from type double
            for (int i = 0; i < PreprocessingData.Columns; ++i)
            {
                if (PreprocessingData.VariableHasType <double>(i))
                {
                    double distinctValueCount = PreprocessingData.GetValues <double>(i).GroupBy(x => x).Count();
                    bool   distinctValuesOk   = distinctValueCount <= MAX_DISTINCT_VALUES_FOR_CLASSIFCATION;
                    if (distinctValuesOk)
                    {
                        doubleVariableNames.Add(PreprocessingData.GetVariableName(i));
                    }
                }
            }
            return(doubleVariableNames);
        }
Ejemplo n.º 4
0
        public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY)
        {
            ScatterPlot scatterPlot = new ScatterPlot();

            IList <double> xValues = PreprocessingData.GetValues <double>(PreprocessingData.GetColumnIndex(variableNameX));
            IList <double> yValues = PreprocessingData.GetValues <double>(PreprocessingData.GetColumnIndex(variableNameY));

            List <Point2D <double> > points = new List <Point2D <double> >();

            for (int i = 0; i < xValues.Count; i++)
            {
                Point2D <double> point = new Point2D <double>(xValues[i], yValues[i]);
                points.Add(point);
            }

            ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points);

            scatterPlot.Rows.Add(scdr);
            return(scatterPlot);
        }