更新 function.py
Gitea Actions Experiment Test / Experiment-Actions (push) Has been cancelled

This commit is contained in:
2024-10-31 17:18:04 +08:00
parent 1765f9d5cc
commit 68ec2ecaa3
+1 -3
View File
@@ -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])