Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultinomialNB Cannot accept negative Alpha #1

Open
JohnMerrick opened this issue Dec 1, 2018 · 0 comments
Open

MultinomialNB Cannot accept negative Alpha #1

JohnMerrick opened this issue Dec 1, 2018 · 0 comments

Comments

@JohnMerrick
Copy link

Hi,

I was trying to run your code on my machine with Phyton 3.7 and at step Multinomial Naive Bayes¶ i get the following error

ValueError Traceback (most recent call last)
in
4 for i in range(-1000,1000,50):
5 clf1 = MultinomialNB(alpha=i)
----> 6 clf1.fit(X_train,y_train)
7 clf1.fit(X_train_2,y_train)
8 scores = cross_val_score(clf1, X_train, y_train, cv=10)

c:\users\johnm\appdata\local\programs\python\python37\lib\site-packages\sklearn\naive_bayes.py in fit(self, X, y, sample_weight)
609 dtype=np.float64)
610 self._count(X, Y)
--> 611 alpha = self._check_alpha()
612 self._update_feature_log_prob(alpha)
613 self._update_class_log_prior(class_prior=class_prior)

c:\users\johnm\appdata\local\programs\python\python37\lib\site-packages\sklearn\naive_bayes.py in check_alpha(self)
471 if np.min(self.alpha) < 0:
472 raise ValueError('Smoothing parameter alpha = %.1e. '
--> 473 'alpha should be > 0.' % np.min(self.alpha))
474 if isinstance(self.alpha, np.ndarray):
475 if not self.alpha.shape[0] == self.feature_count
.shape[1]:

ValueError: Smoothing parameter alpha = -1.0e+03. alpha should be > 0.

It would Appear that the MultinomialNB function cannot accept a negative alpha value, how did you manage to run the code with a negative Alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant