generated from LufsX/Experiment-LogReg
This commit is contained in:
+4
-6
@@ -83,15 +83,13 @@ def load_data(filepath):
|
||||
- np.array: 特征数据。
|
||||
- np.array: 标签数据。
|
||||
"""
|
||||
with open(filepath, 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
X = []
|
||||
y = []
|
||||
with open(filepath, 'r') as f:
|
||||
for line in f:
|
||||
for line in lines:
|
||||
values = line.strip().split()
|
||||
# 检查是否存在 '?' 并跳过这些行
|
||||
if '?' in values:
|
||||
continue
|
||||
# 将标签和特征转换为浮点数
|
||||
y.append(int(values[-1]))
|
||||
X.append([float(x) for x in values[:-1]])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user