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]}")