generated from LufsX/Challenge-SVM
This commit is contained in:
+4
-2
@@ -88,8 +88,10 @@ def load_data(filepath):
|
||||
data = []
|
||||
with open(filepath, 'r') as file:
|
||||
for line in file:
|
||||
if "?" not in line: # 去除包含缺失值的数据行
|
||||
data.append([float(x) for x in line.strip().split()])
|
||||
# 将 "?" 替换为 "0",然后将整行数据转换为浮点数
|
||||
line = line.strip().replace("?", "0")
|
||||
data.append([float(x) for x in line.split()])
|
||||
|
||||
data = np.array(data)
|
||||
X = data[:, :-1] # 所有列,除最后一列
|
||||
y = data[:, -1] # 最后一列
|
||||
|
||||
Reference in New Issue
Block a user