-
-
Save tengpeng/cbc77f2476a79feae0ecfaeea6b9f4d0 to your computer and use it in GitHub Desktop.
cv svm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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