/// <summary>
            /// Compute the output
            /// </summary>
            /// <param name="X">input data of size (n_x,m)</param>
            /// <param name="parameters">output of initialization function, [W1,b1,W2,b2]</param>
            /// <returns>A2(Matrix) -- The sigmoid output of the second activation cache -- a dictionary containing "Z1", "A1", "Z2" and "A2"</returns>
            public static object[] Forward_propagation(Matrix X, Dictionary <string, Matrix> parameters)
            {
                // Retrieve each parameter from the dictionary "parameters"
                Matrix W1 = parameters["W1"];
                Matrix b1 = parameters["b1"];
                Matrix W2 = parameters["W2"];
                Matrix b2 = parameters["b2"];

                // Implement Forward Propagation to calculate A2 (probabilities)
                Matrix Z1 = W1 * X + b1;
                Matrix A1 = Matrix.tanh(Z1); // tanh

                Matrix Z2 = W2 * A1 + b2;
                Matrix A2 = LogisticRegression.Sigmoid(Z2);

                Dictionary <string, Matrix> cache = new Dictionary <string, Matrix>();

                cache.Add("Z1", Z1);
                cache.Add("A1", A1);
                cache.Add("Z2", Z2);
                cache.Add("A2", A2);

                object[] results = { A2, cache };
                return(results);
            }
        public void SigmoidReturnsOpoint5ForZeroValue()
        {
            // arrange

            // act
            var result = LogisticRegression.Sigmoid(0);

            // assert
            Assert.AreEqual(0.5, result, 1E-13);
        }
        public void SigmoidReturnsCorrectResultForTestsData(double value, double expectedResult)
        {
            // arrange

            // act
            var result = LogisticRegression.Sigmoid(value);

            // assert
            var error = Math.Abs(expectedResult - result);

            Assert.Less(error, double.Epsilon);
        }
        public void HypothesisReturnsCorrectResultForTestData()
        {
            // arrange
            IList <double> xs     = new double[] { -1, -2 };
            IList <double> thetas = new double[] { 9, 8, 7 };

            var expectedResult = LogisticRegression.Sigmoid(thetas[0] + thetas[1] * xs[0] + thetas[2] * xs[1]);

            // act
            var result = LogisticRegression.Hypothesis(xs, thetas);

            // assert
            Assert.AreEqual(expectedResult, result, 1E-13);
        }
        public void HypothesisReturnsThetaZeroSigmoidIfXsIsEmpty()
        {
            // arrange
            var rnd            = new Random();
            var randomDouble   = rnd.NextDouble();
            var expectedResult = LogisticRegression.Sigmoid(randomDouble);

            IList <double> xs     = new double[0];
            IList <double> thetas = new double[] { randomDouble };

            // act
            var result = LogisticRegression.Hypothesis(xs, thetas);

            // assert
            Assert.AreEqual(expectedResult, result, 1E-13);
        }