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

This commit is contained in:
2024-10-31 15:58:38 +08:00
parent d7cd1c4d2c
commit 323ab2c1f7
+5 -5
View File
@@ -90,6 +90,10 @@ def preprocess_data(X, y):
# 合并特征 23 的值和删除特征
X, y = preprocess_data_base(X, y)
# 选择特征 23 作为目标变量,将其取值 2(死亡)和 3(安乐死)合并为一个值 0(死亡)
y = np.where(y == 2, 0, y)
y = np.where(y == 3, 0, y)
# 使用库函数进行标准化处理
scaler = StandardScaler()
X = scaler.fit_transform(X)
@@ -97,11 +101,7 @@ def preprocess_data(X, y):
return X, y
def preprocess_data_base(X, y):
"""数据预处理,合并特征 23 的值,并删除特征 3 和特征 24~28。"""
# 合并特征 23 的值:将 2(死亡)和 3(安乐死)合并为 0(死亡)
y = np.where(y == 2, 0, y) # 将值 2 替换为 0
y = np.where(y == 3, 0, y) # 将值 3 替换为 0
"""数据预处理,删除特征 3 和特征 24~28。"""
# 删除特征 3 和特征 24~28(假设特征索引从 0 开始)
X = np.delete(X, [2] + list(range(23, 28)), axis=1)