scikit-learn/scikit-learn — pull request #3944 by ragv (2014-12-07 20:15:06+00:00)
Title: [MRG] GaussianNB.partial_fit - Raise ValueError when there is a mismatch between target and classes argument

In `GaussianNB.partial_fit`, when there is a mismatch between the target labels (or classes) `y` and the `classes` argument,
a `KeyError` while attempting to access the `class2idx` ( refactored to `class_to_index` for readability ) was raised.

Sample code that reproduces this `KeyError`
`gnb.partial_fit(X = [[1,2], [-2,2]], y = [1,2], classes = [0,1])`

* Now a `ValueError` with a message explaining that is raised.
`ValueError: The target label in y does not exist in the initial classes argument, classes=[0, 1]; The conflicting target label is 2`

* Added NRT to test the same.

@GaelVaroquaux Could you take a look at this?