On 01/09/2013 12:38 AM, Andrew Winterman wrote:
I've also posted this question to Stack Overflow. <http://stackoverflow.com/questions/14225882/gridsearch-for-multilabel-onevsrestclassifier%20>I'm trying to use GridSearch for a multilabel problem with OneVsRestClassifier as follows.|#imports from sklearn.svmimport SVC from sklearn.pipelineimport Pipeline from sklearn.decompositionimport RandomizedPCA from sklearn.cross_validationimport StratifiedKFold from sklearn.grid_searchimport 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.pycin fit_grid_point(X, y, base_clf, clf_params, train, test, loss_func, score_func, verbose, **fit_params)107 108 if yis 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 arrayswith one element can be converted to an index| Any idea how to work around this?
Not sure anyone has tried that yet. What is the type and shape of Y and X?
------------------------------------------------------------------------------ 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
