public TestPredictions Decide(TrainerHelper container, DataTable table, string inputId)
        {
            if (container.trainer == null)
            {
                return(null);
            }

            var symbols = container.codification.Apply(table);

            container.columnNamesArray =
                table.Columns.Cast <DataColumn>().Select(x => x.ColumnName).Where(s => s != inputId).ToArray();

            var columnOrdinal = table.Columns[inputId].Ordinal;

            double[][] tempInputs = symbols.ToJagged(container.columnNamesArray);
            double[][] inputs     = new double[tempInputs.Length][];



            var foo         = new TestPredictions();
            var predictions = new List <KeyValuePair <string, double> >();
            var correct     = 0;
            var incorrect   = 0;
            var contents    = new StringBuilder();

            foreach (DataRow x in table.Rows)
            {
                var values = x.ItemArray.Select(c => c.ToString()).ToList();
                var answer = values[columnOrdinal];
                values.RemoveAt(columnOrdinal);
                var prediction = this.Decide(container, values.ToArray(), inputId);

                contents.Append(string.Format("{0},{1},{2}" + Environment.NewLine, answer, prediction.Key, prediction.Value));
                if (answer == prediction.Key)
                {
                    correct++;
                }
                else
                {
                    if (prediction.Value > 75)
                    {
                        incorrect++;
                    }
                }
            }

            File.WriteAllText(@"c:\temp\hack1.txt", contents.ToString());

            int[] outputs = symbols.ToArray <int>(inputId);

            foo.Total     = table.Rows.Count;
            foo.Correct   = correct;
            foo.Incorrect = incorrect;
            foo.Contents  = contents.ToString();
            return(foo);
        }
        public TestPredictions Decide(TrainerHelper container, DataTable table, string inputId)
        {
            if (container.trainer == null)
            {
                return(null);
            }

            var symbols = container.codification.Apply(table);

            container.columnNamesArray =
                table.Columns.Cast <DataColumn>().Select(x => x.ColumnName).Where(s => s != inputId).ToArray();

            var columnOrdinal = table.Columns[inputId].Ordinal;

            double[][] tempInputs = symbols.ToJagged(container.columnNamesArray);
            double[][] inputs     = new double[tempInputs.Length][];
            for (var i = 0; i < tempInputs.Length; i++)
            {
                var flattened = this.ExpandRow(container.codification, tempInputs[i], columnOrdinal);
                inputs[i] = flattened;
            }



            int[] outputs = symbols.ToArray <int>(inputId);



            var foo         = new TestPredictions();
            var predictions = new List <KeyValuePair <string, double> >();
            //foo.Predictions = predictions;
            var predicted       = container.decisionTree.Decide(inputs);
            var predictedValues = container.codification.Revert(inputId, predicted);
            //var confidences = container.trainer.Probabilities(inputs);
            var correct   = 0;
            var incorrect = 0;
            var contents  = new StringBuilder();

            for (var i = 0; i < predicted.Length; i++)
            {
                var predictedAsInt = predicted[i];
                var actualValue    = outputs[i];

                var predictedValue = predictedValues[i];
                //var c = confidences[i];
                var p = 0.0;
                //if (c.Length > 0)
                {
                    //p = c[0];
                }

                p = p * 100;
                if (predictedAsInt == actualValue)
                {
                    correct++;
                }
                else
                {
                    if (p > 75)
                    {
                        incorrect++;
                    }
                }

                var a = new KeyValuePair <string, Double>(predictedValue, p);
                predictions.Add(a);

                contents.Append(string.Format("{0},{1},{2}" + Environment.NewLine, actualValue, predictedValue, p));
            }

            foo.Total     = predicted.Length;
            foo.Correct   = correct;
            foo.Incorrect = incorrect;
            foo.Contents  = contents.ToString();
            return(foo);
        }