In [11]:
import pandas as pd 
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import GaussianNB
import sklearn.svm
from sklearn.svm import SVC
from sklearn.svm import LinearSVC
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier, VotingClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn import preprocessing
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import roc_curve, auc
from sklearn.metrics import confusion_matrix
from sklearn.preprocessing import label_binarize
from sklearn.cross_validation import train_test_split
from sklearn.cross_validation import KFold
from sklearn.cross_validation import StratifiedKFold
from sklearn.cross_validation import cross_val_score
from sklearn.multiclass import OneVsRestClassifier
from sklearn import grid_search
import numpy
from numpy import random
import time
from sklearn.datasets import load_iris

In [13]:
data = load_iris()
X = data.data
y = data.target

linear_clf = grid_search.GridSearchCV(SVC(kernel="linear", class_weight="balanced", probability=True),param_grid={'C': [2**-5, 2**-4, 2**-3, 2**-2, 2**-1, 2**0, 2**1, 2**2, 2**3, 2**4, 2**5, 2**6]},cv=5,n_jobs=1)
rbf_clf = grid_search.GridSearchCV(SVC(class_weight='balanced'),param_grid={'gamma': [2**-5, 2**-4, 2**-3, 2**-2, 2**-1, 2**0, 2**1], 'C': [2**-1, 2**0, 2**1, 2**2, 2**3, 2**4, 2**5, 2**6]},cv=5,n_jobs=-1)

linear_clf.fit(X, y)
rbf_clf.fit(X, y)


Out[13]:
GridSearchCV(cv=5, error_score='raise',
       estimator=SVC(C=1.0, cache_size=200, class_weight='balanced', coef0=0.0,
  decision_function_shape=None, degree=3, gamma='auto', kernel='rbf',
  max_iter=-1, probability=False, random_state=None, shrinking=True,
  tol=0.001, verbose=False),
       fit_params={}, iid=True, n_jobs=-1,
       param_grid={'C': [0.5, 1, 2, 4, 8, 16, 32, 64], 'gamma': [0.03125, 0.0625, 0.125, 0.25, 0.5, 1, 2]},
       pre_dispatch='2*n_jobs', refit=True, scoring=None, verbose=0)

In [22]:
rbf_clf.best_params_
p = linear_clf.best_params_

SVC(**p)


Out[22]:
SVC(C=0.5, cache_size=200, class_weight=None, coef0=0.0,
  decision_function_shape=None, degree=3, gamma='auto', kernel='rbf',
  max_iter=-1, probability=False, random_state=None, shrinking=True,
  tol=0.001, verbose=False)