generated from LufsX/Experiment-LogReg
This commit is contained in:
+4
-1
@@ -54,8 +54,10 @@ def load_data(filepath):
|
|||||||
data, labels = [], []
|
data, labels = [], []
|
||||||
print(f"加载数据中: {filepath}")
|
print(f"加载数据中: {filepath}")
|
||||||
with open(filepath, 'r') as f:
|
with open(filepath, 'r') as f:
|
||||||
for line in f:
|
for line_idx, line in enumerate(f):
|
||||||
line = line.strip().split()
|
line = line.strip().split()
|
||||||
|
if line_idx == 2: # 跳过第三行
|
||||||
|
continue
|
||||||
if len(line) >= 1 and line[-1].isdigit():
|
if len(line) >= 1 and line[-1].isdigit():
|
||||||
line_data = [0 if x == '?' else float(x) for x in line[:-1]]
|
line_data = [0 if x == '?' else float(x) for x in line[:-1]]
|
||||||
data.append(line_data)
|
data.append(line_data)
|
||||||
@@ -67,6 +69,7 @@ def load_data(filepath):
|
|||||||
num_features = data.shape[1]
|
num_features = data.shape[1]
|
||||||
indices_to_remove = [2] # 去掉特征3(索引2)
|
indices_to_remove = [2] # 去掉特征3(索引2)
|
||||||
|
|
||||||
|
# 剔除特征 24-28(索引 23-27)
|
||||||
if num_features > 23:
|
if num_features > 23:
|
||||||
indices_to_remove.extend(range(23, min(28, num_features)))
|
indices_to_remove.extend(range(23, min(28, num_features)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user