diff --git a/CHANGELOG.md b/CHANGELOG.md index f80313f0b2..c5755c533b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,9 +56,10 @@ - PR #3086: Reverting FIL Notebook Testing - PR #3114: Fixed a typo in SVC's predict_proba AttributeError - PR #3117: Fix two crashes in experimental RF backend -- PR #3119: Fix memset args for benchmark +- PR #3119: Fix memset args for benchmark - PR #3130: Return Python string from `dump_as_json()` of RF - PR #3136: Fix stochastic gradient descent example +- PR #3152: Fix access to attributes of individual NB objects in dask NB - PR #3156: Force local conda artifact install # cuML 0.16.0 (Date TBD) diff --git a/python/cuml/dask/naive_bayes/naive_bayes.py b/python/cuml/dask/naive_bayes/naive_bayes.py index 5a749be30a..6dc9bd10a5 100644 --- a/python/cuml/dask/naive_bayes/naive_bayes.py +++ b/python/cuml/dask/naive_bayes/naive_bayes.py @@ -136,8 +136,8 @@ def _merge_counts_to_model(models): modela = first(models) for model in models[1:]: - modela._feature_count_ += model._feature_count_ - modela._class_count_ += model._class_count_ + modela.feature_count_ += model.feature_count_ + modela.class_count_ += model.class_count_ return modela @staticmethod diff --git a/python/cuml/test/dask/test_naive_bayes.py b/python/cuml/test/dask/test_naive_bayes.py index d00b9b9d7e..4064e0f060 100644 --- a/python/cuml/test/dask/test_naive_bayes.py +++ b/python/cuml/test/dask/test_naive_bayes.py @@ -14,13 +14,13 @@ # limitations under the License. # - -from cuml.test.dask.utils import load_text_corpus - -from sklearn.metrics import accuracy_score +import cupy as cp +import dask.array from cuml.dask.naive_bayes import MultinomialNB from cuml.naive_bayes.naive_bayes import MultinomialNB as SGNB +from cuml.test.dask.utils import load_text_corpus +from sklearn.metrics import accuracy_score def test_basic_fit_predict(client): @@ -74,3 +74,20 @@ def test_score(client): y_local = y.compute() assert(accuracy_score(y_hat_local.get(), y_local) == score) + + +def test_model_multiple_chunks(client): + # tests naive_bayes with n_chunks being greater than one, related to issue + # https://github.com/rapidsai/cuml/issues/3150 + X = cp.array([[0, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 0]]) + + X = dask.array.from_array(X, chunks=((1, 1, 1), -1)).astype(cp.int32) + y = dask.array.from_array([1, 0, 0], asarray=False, + fancy=False, chunks=(1)).astype(cp.int32) + + model = MultinomialNB() + model.fit(X, y) + + # this test is a code coverage test, it is too small to be a numeric test, + # but we call score here to exercise the whole model. + assert(0 <= model.score(X, y) <= 1)