From b0689c51fe8429c3d5c221e3a74f0bbebbdc2d3f Mon Sep 17 00:00:00 2001 From: Suyashd999 Date: Sat, 21 Oct 2023 17:15:21 +0530 Subject: [PATCH 1/3] Added doctest for sigmoid_function --- machine_learning/logistic_regression.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/machine_learning/logistic_regression.py b/machine_learning/logistic_regression.py index 87bc8f6681cc..7ec5e3196a9e 100644 --- a/machine_learning/logistic_regression.py +++ b/machine_learning/logistic_regression.py @@ -27,7 +27,22 @@ # classification problems -def sigmoid_function(z): +def sigmoid_function(z): + """ + Also known as Logistic Function. + + 1 + f(x) = ------- + 1 + e⁻ˣ + + The sigmoid function approaches a value of 1 as its input 'x' becomes + increasing positive. Opposite for negative values. + + Reference: https://en.wikipedia.org/wiki/Sigmoid_function + + @param z: input to the function + @returns: returns value in the range 0 to 1 + """ return 1 / (1 + np.exp(-z)) From fd9949922b6e30ba037f9f902f1e558c6a7d03c0 Mon Sep 17 00:00:00 2001 From: Suyashd999 Date: Sat, 21 Oct 2023 17:42:17 +0530 Subject: [PATCH 2/3] Added doctest for sigmoid_function --- machine_learning/logistic_regression.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/machine_learning/logistic_regression.py b/machine_learning/logistic_regression.py index 7ec5e3196a9e..8d0943435c94 100644 --- a/machine_learning/logistic_regression.py +++ b/machine_learning/logistic_regression.py @@ -29,19 +29,19 @@ def sigmoid_function(z): """ - Also known as Logistic Function. + Also known as Logistic Function. - 1 - f(x) = ------- - 1 + e⁻ˣ + 1 + f(x) = ------- + 1 + e⁻ˣ - The sigmoid function approaches a value of 1 as its input 'x' becomes - increasing positive. Opposite for negative values. + The sigmoid function approaches a value of 1 as its input 'x' becomes + increasing positive. Opposite for negative values. - Reference: https://en.wikipedia.org/wiki/Sigmoid_function + Reference: https://en.wikipedia.org/wiki/Sigmoid_function - @param z: input to the function - @returns: returns value in the range 0 to 1 + @param z: input to the function + @returns: returns value in the range 0 to 1 """ return 1 / (1 + np.exp(-z)) From ef23bae6f646bd0a3c6a1a93a0f69c7ed59932af Mon Sep 17 00:00:00 2001 From: Suyashd999 Date: Sat, 21 Oct 2023 17:42:39 +0530 Subject: [PATCH 3/3] Added doctest for sigmoid_function --- machine_learning/logistic_regression.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/machine_learning/logistic_regression.py b/machine_learning/logistic_regression.py index 8d0943435c94..f9da0104ab4b 100644 --- a/machine_learning/logistic_regression.py +++ b/machine_learning/logistic_regression.py @@ -27,21 +27,21 @@ # classification problems -def sigmoid_function(z): +def sigmoid_function(z): """ Also known as Logistic Function. 1 f(x) = ------- 1 + e⁻ˣ - - The sigmoid function approaches a value of 1 as its input 'x' becomes + + The sigmoid function approaches a value of 1 as its input 'x' becomes increasing positive. Opposite for negative values. Reference: https://en.wikipedia.org/wiki/Sigmoid_function - + @param z: input to the function - @returns: returns value in the range 0 to 1 + @returns: returns value in the range 0 to 1 """ return 1 / (1 + np.exp(-z))