From f018ddc4c00f71e7123b780d409550e101e3c673 Mon Sep 17 00:00:00 2001 From: Taru <32308101+epicalyx@users.noreply.github.com> Date: Wed, 17 Oct 2018 00:52:32 +0530 Subject: [PATCH] requested changes addressed --- 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 70c0b2807..2e28fd96b 100644 --- a/machine_learning/logistic_regression.py +++ b/machine_learning/logistic_regression.py @@ -31,13 +31,13 @@ def sigmoid_function(z): def cost_function(h,y): return (-y*np.log(h)-(1-y)*np.log(1-h)).mean() -# here alpha is the learning rate, X is the featue matrix,y is the target matrix +# here alpha is the learning rate, X is the feature matrix,y is the target matrix def logistic_reg(alpha,X,y,max_iterations=70000): converged=False iterations=0 theta=np.zeros(X.shape[1]) - num_iterations=0 + while not converged: z=np.dot(X,theta) h=sigmoid_function(z) @@ -46,9 +46,9 @@ def logistic_reg(alpha,X,y,max_iterations=70000): z=np.dot(X,theta) h=sigmoid_function(z) - e=cost_function(h,y) - print('J=',e) - J=e + J=cost_function(h,y) + + iterations+=1 #update iterations