MCPcopy Index your code
hub / github.com/rushter/MLAlgorithms / LogisticRegression

Class LogisticRegression

mla/linear_models.py:122–138  ·  view source on GitHub ↗

Binary logistic regression with gradient descent optimizer.

Source from the content-addressed store, hash-verified

120
121
122class LogisticRegression(BasicRegression):
123 """Binary logistic regression with gradient descent optimizer."""
124
125 def init_cost(self):
126 self.cost_func = binary_crossentropy
127
128 def _loss(self, w):
129 loss = self.cost_func(self.y, self.sigmoid(np.dot(self.X, w)))
130 return self._add_penalty(loss, w)
131
132 @staticmethod
133 def sigmoid(x):
134 return 0.5 * (np.tanh(0.5 * x) + 1)
135
136 def _predict(self, X=None):
137 X = self._add_intercept(X)
138 return self.sigmoid(X.dot(self.theta))

Callers 3

test_linear_modelFunction · 0.90
pca.pyFile · 0.90
classificationFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_linear_modelFunction · 0.72