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

This commit is contained in:
2024-11-11 23:37:45 +08:00
parent 1440576edd
commit 595bb49fa0
+2 -2
View File
@@ -31,7 +31,7 @@ name = "李燕如"
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def train_logreg(X, y, learning_rate=0.01, iterations=1000, regularization=0.01):
def train_logreg(X, y, learning_rate=0.001, iterations=2000, regularization=0.01):
m, n = X.shape
weights = np.zeros(n)
for _ in range(iterations):
@@ -95,7 +95,7 @@ def main():
X_test = scaler.transform(X_test)
# 训练模型
weights = train_logreg(X_train, y_train, learning_rate=0.01, iterations=1000, regularization=0.1)
weights = train_logreg(X_train, y_train, learning_rate=0.001, iterations=2000, regularization=0.01)
# 预测测试集
y_pred = [predict_logreg(x, weights) for x in X_test]