Applied#
from sklearn.svm import SVC
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.datasets import make_blobs
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(rc={'figure.figsize':(11.7,8.27)})
centers = [(-3, -3), (2, 2)]
cluster_std = [1, 1]
X, y = make_blobs(
n_samples=500,
cluster_std = cluster_std,
centers = centers,
n_features = 2,
random_state=2
)
pipe = Pipeline(
[
('scaler', StandardScaler()),
('clf', SVC())
]
)
param_grid = {
'clf__C': np.logspace(0, 4, 10)
}
search = GridSearchCV(
estimator=pipe,
param_grid=param_grid,
cv=5,
n_jobs=10,
scoring='accuracy',
refit="roc_auc",
)
search.fit(X,y)
GridSearchCV(cv=5, estimator=Pipeline(steps=[('scaler', StandardScaler()), ('clf', SVC())]), n_jobs=10, param_grid={'clf__C': array([1.00000000e+00, 2.78255940e+00, 7.74263683e+00, 2.15443469e+01, 5.99484250e+01, 1.66810054e+02, 4.64158883e+02, 1.29154967e+03, 3.59381366e+03, 1.00000000e+04])}, refit='roc_auc', scoring='accuracy')In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
GridSearchCV(cv=5, estimator=Pipeline(steps=[('scaler', StandardScaler()), ('clf', SVC())]), n_jobs=10, param_grid={'clf__C': array([1.00000000e+00, 2.78255940e+00, 7.74263683e+00, 2.15443469e+01, 5.99484250e+01, 1.66810054e+02, 4.64158883e+02, 1.29154967e+03, 3.59381366e+03, 1.00000000e+04])}, refit='roc_auc', scoring='accuracy')
Pipeline(steps=[('scaler', StandardScaler()), ('clf', SVC())])
StandardScaler()
SVC()