MCPcopy
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / stocGradAscent0

Function stocGradAscent0

Logistic regression/Logistic.py:29–37  ·  view source on GitHub ↗
(dataMatrix, classLabels)

Source from the content-addressed store, hash-verified

27 return weights
28
29def stocGradAscent0(dataMatrix, classLabels):
30 m, n = shape(dataMatrix)
31 alpha = 0.01
32 weights = ones(n)
33 for i in range(m):
34 h = sigmoid(sum(dataMatrix[i]*weights))
35 error = classLabels[i] - h
36 weights = weights + alpha * error * dataMatrix[i]
37 return weights
38
39def stocGradAscent1(dataMatrix, classLabels, numIter=150):
40 m, n = shape(dataMatrix)

Callers

nothing calls this directly

Calls 1

sigmoidFunction · 0.85

Tested by

no test coverage detected