def test_poissonnb_prior(): """Test whether class priors are properly set. """ Xp = X + np.array([2, 2]) clf = PoissonNB().fit(Xp, y) assert_array_almost_equal(np.array([3, 3]) / 6.0, clf.class_prior_, 8) clf.fit(X2, y2) assert_array_almost_equal(clf.class_prior_.sum(), 1) # Verify that np.log(clf.predict_proba(X)) gives the same results as # clf.predict_log_proba(X) y_pred_proba = clf.predict_proba(X2) y_pred_log_proba = clf.predict_log_proba(X2) assert_array_almost_equal(np.log(y_pred_proba), y_pred_log_proba, 8)
def test_poissonnb(): clf = PoissonNB() assert_raises(ValueError, clf.fit, -X2, y2) y_pred = clf.fit(X2, y2).predict(X2) assert_array_equal(y_pred, y2)