Skip to content

Instantly share code, notes, and snippets.

@tengpeng
Created April 10, 2016 21:05
Show Gist options
  • Save tengpeng/cbc77f2476a79feae0ecfaeea6b9f4d0 to your computer and use it in GitHub Desktop.
Save tengpeng/cbc77f2476a79feae0ecfaeea6b9f4d0 to your computer and use it in GitHub Desktop.
cv svm
from sklearn.datasets import load_iris
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import SVC
from sklearn.grid_search import GridSearchCV
from sklearn.metrics import f1_score
model_to_set = OneVsRestClassifier(SVC())
parameters = {
"estimator__C": [2e-5, 2e-3, 2e-1, 2e1, 2e3, 2e5, 2e7, 2e9, 2e11, 2e13, 2e15],
"estimator__kernel": ["rbf"],
"estimator__degree":[2e-15, 2e-13, 2e-11, 2e-9, 2e-7, 2e-5, 2e-3, 2e-1, 2e1, 2e3],
}
model_tunning = GridSearchCV(model_to_set, param_grid=parameters,scoring='f1_micro',n_jobs=-1)
model_tunning.fit(X_ptrain, y_ptrain)
print model_tunning.best_score_
print model_tunning.best_params_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment