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