更新 function.py
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 31s

This commit is contained in:
2024-11-02 16:18:54 +08:00
parent 4c0d41e48a
commit 7f8acce543
+10 -3
View File
@@ -94,9 +94,16 @@ def load_data(filepath):
data = np.array(data)
labels = np.array(labels)
# 特征选择:去掉特征3、特征24~28
# 特征3的索引是2,特征24~28的索引是23到27
data = np.delete(data, [2] + list(range(23, 28)), axis=1)
# 特征选择:去掉特征3(索引2)和特征24~28(索引23到27),检查数据的形状
num_features = data.shape[1] # 获取特征的总数
indices_to_remove = [2] # 特征3的索引是2
# 仅在数据的特征数量足够时才删除特征24~28
if num_features > 23:
indices_to_remove.extend(range(23, min(28, num_features))) # 从特征24开始到特征28
data = np.delete(data, indices_to_remove, axis=1)
# 将标签二分类化,2(死亡)和3(安乐死)合并为0,其余为1
target_variable = np.where((labels == 2) | (labels == 3), 0, 1)