# Workaround on using Grid Search when we have scipy.sparse.csr.csr_matrix

I am reviewing some techniques based on scikit-learn and I would like to check what are the best parameters for SVM using Grid Search.

The thing is that I don't know how to use Grid Search to the code below although I have used it in the past successfully for simpler cases:

Obviously sparse matrix and Grid Search can't work together.

From your experience, what is the way to find the best parameters given what I have here?

clf=CalibratedClassifierCV(OneVsRestClassifier(SVC(C=1)))
clf.fit(tr_data, df.type)


where tr_data looks like this:

  (0, 127887)   0.093453466346
(0, 13358)    0.276756756575
(0, 20712)    0.165645654645
(0, 13423)    0.076765456536
(0, 3653)     0.178745322453


and df.type like this:

0       alt.atheism
1       alt.atheism
2       alt.atheism
3       alt.atheism


Tried something like this but has problem with the matrix I guess:

alphas = np.array([1,0.1,0.01,0.001,0.0001,0])
grid = grid_search.GridSearchCV(estimator = clf,param_grid = dict(alpha=alphas))


Any help will be much appreciated