Skip forbidden parameter combinations when using GridSearchCV : <p>I want to greedily search the entire parameter space of my support vector classifier using <a href="http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html" rel="noreferrer">GridSearchCV</a>. However, some combinations of parameters are forbidden by <a href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html" rel="noreferrer">LinearSVC</a> and <a href="https://stackoverflow.com/questions/29902190/value-error-happens-when-using-gridsearchcv">throw an exception</a>. In particular, there are mutually exclusive combinations of the <code>dual</code>, <code>penalty</code>, and <code>loss</code> parameters:</p>

<p>For example, this code:</p>

<pre><code>from sklearn import svm, datasets
from sklearn.model_selection import GridSearchCV

iris = datasets.load_iris()
parameters = {'dual':[True, False], 'penalty' : ['l1', 'l2'], \
              'loss': ['hinge', 'squared_hinge']}
svc = svm.LinearSVC()
clf = GridSearchCV(svc, parameters)
clf.fit(iris.data, iris.target)
</code></pre>

<p>Returns <code>ValueError: Unsupported set of arguments: The combination of penalty='l2' and loss='hinge' are not supported when dual=False, Parameters: penalty='l2', loss='hinge', dual=False</code></p>

<p>My question is: is it possible to make GridSearchCV skip combinations of parameters which the model forbids? If not, is there an easy way to construct a parameter space which won't violate the rules?</p>
