generated from LufsX/Challenge-SVM
This commit is contained in:
+4
-5
@@ -56,10 +56,9 @@ def load_data(filepath):
|
||||
X = data[:, :-1] # 特征数据(假设最后一列是目标变量)
|
||||
y = data[:, 23] # 特征23作为目标变量
|
||||
|
||||
# 转换目标变量为 1 (lived), 2 (died), 3 (euthanized)
|
||||
y = np.where(y == 2, 0, y) # 2 -> 0 (died -> death)
|
||||
y = np.where(y == 3, 0, y) # 3 -> 0 (euthanized -> death)
|
||||
|
||||
# 不合并死亡与安乐死,直接使用原始标签
|
||||
# 1 = lived, 2 = died, 3 = euthanized
|
||||
|
||||
# 将缺失值填充为 0(或其他合适的值)
|
||||
X = np.nan_to_num(X, nan=0)
|
||||
|
||||
@@ -122,4 +121,4 @@ if __name__ == "__main__":
|
||||
correct += 1
|
||||
|
||||
accuracy = correct / len(X_test) * 100
|
||||
print(f"测试集准确率: {accuracy}%")
|
||||
print(f"测试集准确率: {accuracy}%")
|
||||
Reference in New Issue
Block a user