Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop was fixed. #1105

Merged
merged 4 commits into from
Aug 7, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions machine_learning/logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ def logistic_reg(
z = np.dot(X, theta)
h = sigmoid_function(z)
gradient = np.dot(X.T, h - y) / y.size
theta = theta - alpha * gradient #updating the weights
theta = theta - alpha * gradient # updating the weights
z = np.dot(X, theta)
h = sigmoid_function(z)
J = cost_function(h, y)
if iterations % 100 == 0:
print(f'loss: {J} \t') #printing the loss after every 100 iterations
print(f'loss: {J} \t') # printing the loss after every 100 iterations
return theta

# In[68]:
Expand All @@ -65,11 +65,11 @@ def logistic_reg(

alpha = 0.1
theta = logistic_reg(alpha,X,y,max_iterations=70000)
print("theta: ",theta) #printing the theta i.e our weights vecto
print("theta: ",theta) # printing the theta i.e our weights vecto


def predict_prob(X):
return sigmoid_function(np.dot(X, theta)) # predicting the value of probability from the logistic regression algorithm
return sigmoid_function(np.dot(X, theta)) # predicting the value of probability from the logistic regression algorithm
AmritK10 marked this conversation as resolved.
Show resolved Hide resolved


plt.figure(figsize=(10, 6))
Expand All @@ -91,4 +91,4 @@ def predict_prob(X):
)

plt.legend()
plt.show()
plt.show()