From e60dfb39cb4934a91683b74d4067f28a84622e8c Mon Sep 17 00:00:00 2001 From: Yijuehen <1906265724@qq.com> Date: Wed, 20 Nov 2024 16:18:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20function.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/function.py b/function.py index b1f689a..b9f423d 100644 --- a/function.py +++ b/function.py @@ -70,7 +70,7 @@ def train_svm(X, y, other_params=None): Returns: - SVC: 训练好的SVM模型。 """ - # 使用高斯核(RBF核)训练SVM + # 使用高斯核(RBF核)训练SVM model = SVC(kernel='rbf', C=1.0, gamma='scale', random_state=42) model.fit(X, y) @@ -120,6 +120,6 @@ if __name__ == "__main__": print(f"测试集准确率: {accuracy * 100:.2f}%") # 测试单个数据 - test_sample = X_test[11] # 选择第12个样本(从0开始计数) + test_sample = X_test[11] # 选择第12个样本(从0开始计数) y_pred_single = predict_svm(test_sample, svm_model) print(f"\n单个样本预测结果: {y_pred_single}, 实际结果: {y_test[11]}")