generated from LufsX/Experiment-LogReg
This commit is contained in:
+1
-12
@@ -83,18 +83,7 @@ def load_data(filepath):
|
||||
for line in f:
|
||||
line = line.strip().split()
|
||||
if len(line) >= 1 and line[-1].isdigit():
|
||||
line_data = []
|
||||
for x in line[:-1]:
|
||||
if x == '?':
|
||||
# 用均值填充缺失值
|
||||
data_array = np.array(data)
|
||||
if len(data_array) > 0:
|
||||
column_mean = np.nanmean(data_array[:, len(line_data)], axis=0)
|
||||
line_data.append(column_mean)
|
||||
else:
|
||||
line_data.append(0)
|
||||
else:
|
||||
line_data.append(float(x))
|
||||
line_data = [0 if x == '?' else float(x) for x in line[:-1]]
|
||||
data.append(line_data)
|
||||
labels.append(int(line[-1]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user