From 568f7487bbc1851ed0e1a1d30e54d954b59dd850 Mon Sep 17 00:00:00 2001 From: system Date: Wed, 11 Sep 2024 13:43:24 +0800 Subject: [PATCH] =?UTF-8?q?Delete=20hpo=20-=20=E5=89=AF=E6=9C=AC.PY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: system --- hpo - 副本.PY | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 hpo - 副本.PY diff --git a/hpo - 副本.PY b/hpo - 副本.PY deleted file mode 100644 index 9130867..0000000 --- a/hpo - 副本.PY +++ /dev/null @@ -1,31 +0,0 @@ -from sklearn.datasets import load_iris -from sklearn.model_selection import train_test_split -from sklearn.svm import SVC -import argparse - -# 加载数据集 -iris = load_iris() -X = iris.data -y = iris.target - -# 划分数据集 -X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) - -# 参数解析 -parser = argparse.ArgumentParser(description='SVM Model for Iris dataset') -parser.add_argument('--C', type=float, default=1.0, help='Regularization parameter') -parser.add_argument('--kernel', type=str, default='rbf', help='Kernel type') -parser.add_argument('--gamma', type=float, default='scale', help='Kernel coefficient') - -args = parser.parse_args() - -# 定义支持向量机模型并设置参数 -svm = SVC(C=args.C, kernel=args.kernel, gamma=args.gamma) - -# 在训练集上拟合模型 -svm.fit(X_train, y_train) - -# 输出模型在测试集上的准确率 -test_accuracy = svm.score(X_test, y_test) -print(f"Accuracy={test_accuracy}") -