generated from LufsX/Challenge-SVM
This commit is contained in:
+4
-3
@@ -1,6 +1,6 @@
|
|||||||
# function.py
|
# function.py
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
data_columns=[]
|
||||||
id = "202210423230"
|
id = "202210423230"
|
||||||
name = "尹家立"
|
name = "尹家立"
|
||||||
|
|
||||||
@@ -8,7 +8,8 @@ import pandas as pd
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from sklearn.impute import SimpleImputer
|
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 = pd.read_csv(data_path, header=None, sep=r"\s+")
|
||||||
horse_data = horse_data.loc[:, :22] # 只取到死亡情况(前23列,索引0-22)
|
horse_data = horse_data.loc[:, :22] # 只取到死亡情况(前23列,索引0-22)
|
||||||
@@ -107,7 +108,7 @@ def predict_svm(inX, weights):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
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_names = f.read()
|
||||||
data_columns = re.findall(r'(?<=[0-9]:).*', data_names)
|
data_columns = re.findall(r'(?<=[0-9]:).*', data_names)
|
||||||
data_columns = [col.strip() for col in data_columns[:-3]]
|
data_columns = [col.strip() for col in data_columns[:-3]]
|
||||||
|
|||||||
Reference in New Issue
Block a user