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

This commit is contained in:
2024-11-13 19:09:00 +08:00
parent 27673b3993
commit 56c2bad4d7
+4 -3
View File
@@ -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]]