scikit-learn/scikit-learn — pull request #1087 by cjauvin (2012-08-30 16:41:19+00:00)
Title: Mechanism to propagate optional estimator.fit arguments when using CV

Instead of opening a feature request for this issue:

http://stackoverflow.com/questions/12131472/additional-fitting-parameters-for-cross-validation

I decided to propose a possible solution. In a nutshell, what it allows to do:

```python
>>> import numpy as np
>>> from sklearn.cross_validation import cross_val_score
>>> from sklearn.naive_bayes import MultinomialNB
>>> n_samples, n_classes = 100, 5
>>> X = np.random.randint(10, size=(n_samples, n_samples))
>>> y = np.arange(n_classes)
>>> clf = MultinomialNB()
>>> print cross_val_score(clf, X, y, cv=5,
class_prior=[0.2] * n_classes, # those two params will be
sample_weight=[0.01] * n_samples) # propagated to clf.fit
```

I'll admit that as a sklearn newbie, I may not be aware of all the possible effects this addition might have on other types of estimator (I only tested it in the context of a `MultinomialNB`). Also, it's quite possible that it could be generalized in a better way, as similar problems likely show up elsewhere in the codebase. Nevertheless, I thought it could be an easy and useful modification.