From 19e9eabc43f61b9be81788f2f11d31b164d2b69f Mon Sep 17 00:00:00 2001 From: zhangchenghong <1598349064@qq.com> Date: Sat, 2 Nov 2024 15:38:19 +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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/function.py b/function.py index bf27ae3..d8d6277 100644 --- a/function.py +++ b/function.py @@ -27,7 +27,7 @@ name = "章程鸿" # 这里写自己的代码实现 import numpy as np -from sklearn.preprocessing import StandardScaler, MinMaxScaler +from sklearn.preprocessing import MinMaxScaler from sklearn.model_selection import train_test_split def sigmoid(z): @@ -87,7 +87,8 @@ def load_data(filepath): data = np.array(data) labels = np.array(labels) - target_variable = np.where((labels == 2) | (labels == 3), 0, labels) + # 将标签二分类化,2和3为0,其余为1 + target_variable = np.where((labels == 2) | (labels == 3), 0, 1) return data, target_variable @@ -121,6 +122,6 @@ if __name__ == "__main__": # 测试模型 final_test_accuracy = accuracy(X_test, y_test, final_weights) print(f"最终测试集的准确率: {final_test_accuracy:.4f}") - +