Skip to content

Instantly share code, notes, and snippets.

@elyase
Last active December 25, 2015 22:29
Show Gist options
  • Save elyase/7050488 to your computer and use it in GitHub Desktop.
Save elyase/7050488 to your computer and use it in GitHub Desktop.
# Split the dataset in two equal parts
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.5, random_state=0)
# Set the parameters by cross-validation
tuned_parameters = [{'kernel': ['rbf'], 'gamma': [1e-3, 1e-4],
'C': [1, 10, 100, 1000]},
{'kernel': ['linear'], 'C': [1, 10, 100, 1000]}]
model = GridSearchCV(SVC(C=1), tuned_parameters, cv=5, scoring=score)
model.fit(X_train, y_train)
print(model.best_estimator_)
y_true, y_pred = y_test, model.predict(X_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment