You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: