/// <summary>
        ///
        /// </summary>
        /// <param name="times"></param>
        /// <returns>The cost of each iteration</returns>
        public List <BinaryClassificationTrainResult> Train(int times)
        {
            List <BinaryClassificationTrainResult> results = new List <BinaryClassificationTrainResult>();

            //double[] costs = new double[times];
            sampleCount = samples.Count;
            x           = new double[sampleCount, featureCount_plus_1];
            y           = new double[sampleCount];
            Theta       = MLMath.GetRandomVector(featureCount_plus_1, 0, 1);
            for (int i = 0; i < sampleCount; i++)
            {
                x[i, 0] = 1;
                for (int j = 0; j < featureCount_plus_1 - 1; j++)
                {
                    x[i, j + 1] = samples[i].X[j];
                }
                y[i] = samples[i].Y;
            }

            for (int i = 0; i < times; i++)
            {
                Tuple <double, double[]> costFunction = CostFunction();
                Theta = MLMath.Add(Theta, costFunction.Item2);
                BinaryClassificationTrainResult result = new BinaryClassificationTrainResult();
                result.Cost  = costFunction.Item1;
                result.Theta = Theta;
                results.Add(result);
            }
            return(results);
        }
        public LogisticClassifier(int featureNumber, double alpha = 0.1, double lambda = 0)
        {
            this.Alpha  = alpha;
            this.Lambda = lambda;

            featureCount_plus_1 = featureNumber + 1;
            Theta = MLMath.GetRandomVector(featureCount_plus_1, 0, 1);
        }
 public void GetRandomVectorTest()
 {
     double[] r = MLMath.GetRandomVector(10, 0, 1);
     foreach (double d in r)
     {
         Debug.Print(d.ToString());
     }
     Assert.AreNotEqual(r[0], r[1]);
     Assert.AreNotEqual(r[2], r[3]);
     Assert.AreNotEqual(r[3], r[1]);
     Assert.AreNotEqual(r[5], r[1]);
 }