更新 function.py
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 12s

This commit is contained in:
2024-10-31 16:47:52 +08:00
parent 8f8a908914
commit 7cba228d95
+4
View File
@@ -47,6 +47,10 @@ def train_logreg(X, y, learning_rate=0.01, iterations=1000):
z = np.dot(X, weights)
predictions = 1 / (1 + np.exp(-z))
gradient = np.dot(X.T, (predictions - y)) / m
# L2正则化
gradient += (lambda_reg / m) * weights
weights -= learning_rate * gradient
return weights