From 56c2bad4d7b1c219108c022287dd6477dd85e327 Mon Sep 17 00:00:00 2001 From: Yijuehen <1906265724@qq.com> Date: Wed, 13 Nov 2024 19:09:00 +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 014351d..bba6f81 100644 --- a/function.py +++ b/function.py @@ -1,6 +1,6 @@ # function.py import numpy as np - +data_columns=[] id = "202210423230" name = "尹家立" @@ -8,7 +8,8 @@ import pandas as pd import numpy as np from sklearn.impute import SimpleImputer -def load_data(data_path, NAN_THRES=0.5): +def load_data(data_path): + NAN_THRES=0.5 # 读取数据并指定列 horse_data = pd.read_csv(data_path, header=None, sep=r"\s+") horse_data = horse_data.loc[:, :22] # 只取到死亡情况(前23列,索引0-22) @@ -107,7 +108,7 @@ def predict_svm(inX, weights): if __name__ == "__main__": # 取得列信息 - with open("resources/horse-colic.names", 'r', encoding='utf-8') as f: + with open("./data/horse-colic.names", 'r', encoding='utf-8') as f: data_names = f.read() data_columns = re.findall(r'(?<=[0-9]:).*', data_names) data_columns = [col.strip() for col in data_columns[:-3]]