from sklearn import svm import numpy as np import time from sklearn.model_selection import ShuffleSplit from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn.model_selection import GridSearchCV from matplotlib import pyplot as plt from ROC import plot_learning_curve cancer = load_breast_cancer() X = cancer.data y = cancer.target X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) # C表示错误可接受的范围,kernel 表示所选择的核函数,gamma时对应选择高斯核的参数 # clf_rbf = svm.SVC(C=1.0, kernel='rbf', gamma=0.1) # clf_rbf.fit(X_train, y_train) # # train_score = clf_rbf.score(X_train, y_train) # test_score = clf_rbf.score(X_test, y_test) # # print("train score:{0}; test score:{1}".format(train_score, test_score)) # # 计算出最佳的gamma值 # gammas = np.linspace(0, 0.0003, 30) # param_grid = {'gamma': gammas} # clf = GridSearchCV(svm.SVC(), param_gr
sklearn----SVM高斯核与多项式核函数
最新推荐文章于 2024-05-21 06:30:00 发布