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

This commit is contained in:
2024-10-31 17:20:54 +08:00
parent c0394d11d0
commit 795f0cf7a3
+2 -2
View File
@@ -32,7 +32,7 @@ def sigmoid(intX):
return 1.0 / (1 + np.exp(-intX))
def stocGradAscent1(X, y, numIter=150):
def train_logreg(X, y, numIter=150):
m, n = X.shape
weights = np.ones(n)
for j in range(numIter):
@@ -84,7 +84,7 @@ def accuracy(X, y, weights):
def colicTest():
X_train, y_train = load_data("./horse-colic.data")
X_test, y_test = load_data("./horse-colic.test")
trainWeights = stocGradAscent1(X_train, y_train, 500)
trainWeights = train_logreg(X_train, y_train, 500)
errorCount = 0
numTestVec = 0.0
for x, true_label in zip(X_test, y_test):