Function
stocGradAscent0
(dataMatrix, classLabels)
Source from the content-addressed store, hash-verified
| 27 | return weights |
| 28 | |
| 29 | def 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 | |
| 39 | def stocGradAscent1(dataMatrix, classLabels, numIter=150): |
| 40 | m, n = shape(dataMatrix) |
Callers
nothing calls this directly
Tested by
no test coverage detected