From 795f0cf7a3032c5d129d90d8ed4930a4658aeff9 Mon Sep 17 00:00:00 2001 From: Dengddd <3149942468@qq.com> Date: Thu, 31 Oct 2024 17:20:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20function.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/function.py b/function.py index 8e039d7..e144c58 100644 --- a/function.py +++ b/function.py @@ -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):