generated from LufsX/Experiment-LogReg
This commit is contained in:
+1
-3
@@ -26,8 +26,6 @@ name = "邓龙树"
|
|||||||
|
|
||||||
# user_code.py
|
# user_code.py
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import random
|
|
||||||
from sklearn.preprocessing import StandardScaler
|
from sklearn.preprocessing import StandardScaler
|
||||||
|
|
||||||
def sigmoid(intX):
|
def sigmoid(intX):
|
||||||
@@ -41,7 +39,7 @@ def stocGradAscent1(X, y, numIter=150):
|
|||||||
dataIndex = list(range(m))
|
dataIndex = list(range(m))
|
||||||
for i in range(m):
|
for i in range(m):
|
||||||
alpha = 4 / (1.0 + j + i) + 0.01
|
alpha = 4 / (1.0 + j + i) + 0.01
|
||||||
randIndex = int(random.uniform(0, len(dataIndex)))
|
randIndex = int(np.random.uniform(0, len(dataIndex)))
|
||||||
h = sigmoid(np.dot(X[randIndex], weights))
|
h = sigmoid(np.dot(X[randIndex], weights))
|
||||||
error = y[randIndex] - h
|
error = y[randIndex] - h
|
||||||
weights = weights + np.dot(alpha * error, X[randIndex])
|
weights = weights + np.dot(alpha * error, X[randIndex])
|
||||||
|
|||||||
Reference in New Issue
Block a user