Skip to content

Commit

Permalink
Update logistic_regression.py (#64)
Browse files Browse the repository at this point in the history
Correction to the cost function: since the function is J(\theta) = 1/m \sum -ylog(h) - (1-y)*(1-h), the cost variable should be set to cost_1 - cost_2, not cost_1 + cost_2
  • Loading branch information
theandyb authored and bfortuner committed Oct 12, 2019
1 parent ad7b440 commit 7c56b37
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion code/logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def cost_function(features, labels, weights):
class2_cost = (1-labels)*np.log(1-predictions)

#Take the sum of both costs
cost = class1_cost + class2_cost
cost = class1_cost - class2_cost

#Take the average cost
cost = cost.sum() / observations
Expand Down

0 comments on commit 7c56b37

Please sign in to comment.