generated from LufsX/Challenge-SVM
This commit is contained in:
+2
-2
@@ -54,7 +54,7 @@ def load_data(filepath):
|
||||
|
||||
# 选择特征和标签
|
||||
X = data[:, :-1] # 特征数据(假设最后一列是目标变量)
|
||||
y = data[:, 23] # 特征23作为目标变量
|
||||
y = data[:, -1] # 最后一列作为目标变量
|
||||
|
||||
# 不合并死亡与安乐死,直接使用原始标签
|
||||
# 1 = lived, 2 = died, 3 = euthanized
|
||||
@@ -81,7 +81,7 @@ def train_svm(X, y):
|
||||
X_scaled = scaler.fit_transform(X)
|
||||
|
||||
# 使用RBF核的SVM模型
|
||||
model = SVC(kernel='rbf', decision_function_shape='ovr') # 采用RBF核
|
||||
model = SVC(kernel='rbf', decision_function_shape='ovo') # 采用RBF核,多类分类使用'ovo'
|
||||
model.fit(X_scaled, y)
|
||||
|
||||
return model, scaler
|
||||
|
||||
Reference in New Issue
Block a user