2
$\begingroup$

When I try to do

mnb = MultinomialNB() 
mnb.fit(train_glove_features, train_targ) 

I get the below error:

ValueError: Input X must be non-negative

I do understand that GloVe embedding has negative numbers in the matrix, and that naive bayes cannot accept them, is there any workaround or is it that MultinomialNB cannot be used with GloVe?

Background: I am trying to apply GloVe embedding I created train_glove_features as

train_nlp = [nlp2(item) for item in train_art]    
train_glove_features = np.array([item.vector for item in train_nlp])
$\endgroup$

1 Answer 1

3
$\begingroup$

You can't use it with Multinomial Naive Bayes because it works with integer values (counts), although fractional counts are also possible to use; but not negative values. Gaussian Naive Bayes might be better suited for your case.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.