I've also posted this question to Stack
Overflow.<http://stackoverflow.com/questions/14225882/gridsearch-for-multilabel-onevsrestclassifier>

I'm trying to use GridSearch for a multilabel problem with
OneVsRestClassifier as follows.

#importsfrom sklearn.svm import SVCfrom sklearn.pipeline import
Pipelinefrom sklearn.decomposition import RandomizedPCAfrom
sklearn.cross_validation import StratifiedKFoldfrom
sklearn.grid_search import GridSearchCV
#classifier pipeline
clf_pipeline = clf_pipeline = OneVsRestClassifier(
                Pipeline([('reduce_dim', RandomizedPCA()),
                          ('clf', classifier())
                          ]
                         ))

C_range = 10.0 ** np.arange(-2, 9)
gamma_range = 10.0 ** np.arange(-5, 4)
n_components_range = (10, 100, 200)
degree_range = (1, 2, 3, 4)

grid = GridSearchCV(clf_pipeline, param_grid,
                                cv=StratifiedKFold(y=Y, n_folds=3), n_jobs=1,
                                verbose=2)
grid.fit(X, Y)

I'm seeing:

/Users/andrewwinterman/Documents/sparks-honey/classifier/lib/python2.7/site-packages/sklearn/grid_search.pyc
in fit_grid_point(X, y, base_clf, clf_params, train, test, loss_func,
score_func, verbose, **fit_params)
    107
    108     if y is not None:--> 109         y_test = y[safe_mask(y, test)]
    110         y_train = y[safe_mask(y, train)]
    111         clf.fit(X_train, y_train, **fit_params)
TypeError: only integer arrays with one element can be converted to an index


Any idea how to work around this?


-- 
Andrew Winterman
714 362 6823
------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to