Hi Daan. This looks like a bug, please open a pull request. Are you doing multi-label classification? For multi-class, SVC already has built-in OvR support.
Best, Andy On 09/11/2015 04:17 AM, Daan Wynen wrote: > Hi all, > > I recently was in the position of wanting to use a OneVsRest SVC for ~50 > classes. > It turned out that this was not easily possible with sklearn because the > GridSearchCV class queries the classifier's _pairwise property to see if > the data is a square matrix and should be sliced in both dimensions or > if it is a matrix that only needs to be sliced in the first dimension. > > What works for me is adding these lines to the MetaEstimatorMixin in > ./base.py: > > class MetaEstimatorMixin(object): > """Mixin class for all meta estimators in scikit-learn.""" > > @property > def _pairwise(self): > # Used by cross_val_score. > return getattr(self.estimator, "_pairwise", False) > > > OneVsRestClassifier uses this mixin which so far was just a flag. > Now it takes the property from the wrapped class. > Is there a good reason why this was not the case before?Any pitfalls I > don't see coming at the moment? > > Thanks for your input > /Daan > > > ------------------------------------------------------------------------------ > _______________________________________________ > Scikit-learn-general mailing list > Scikit-learn-general@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/scikit-learn-general ------------------------------------------------------------------------------ _______________________________________________ Scikit-learn-general mailing list Scikit-learn-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/scikit-learn-general