MCPcopy Index your code
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / gradAscent

Function gradAscent

Logistic regression/Logistic.py:16–27  ·  view source on GitHub ↗
(dataMatIn, classLabels)

Source from the content-addressed store, hash-verified

14 return 1/(1+exp(-inX))
15
16def gradAscent(dataMatIn, classLabels):
17 dataMatrix = mat(dataMatIn)
18 labelMat = mat(classLabels).transpose()
19 m, n = shape(dataMatrix)
20 alpha = 0.001
21 maxCycles = 500
22 weights = ones((n, 1))
23 for k in range(maxCycles):
24 h = sigmoid(dataMatrix*weights)
25 error = (labelMat - h)
26 weights += alpha * dataMatrix.transpose() * error
27 return weights
28
29def stocGradAscent0(dataMatrix, classLabels):
30 m, n = shape(dataMatrix)

Callers

nothing calls this directly

Calls 1

sigmoidFunction · 0.85

Tested by

no test coverage detected