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

Error while implementing the Naive Bayes approach to generate sentiment scores for movie reviews in NLPIA #33

Open
SallyAfua opened this issue Apr 17, 2020 · 1 comment

Comments

@SallyAfua
Copy link

Hello NLPIA readers. Please I tried to implement the code snippet on generating sentiment scores for movie reviews in the NLPIA.

This line of code

'' movies['predicted_sentiment'] = nb.predict_proba(df_bows) * 8 - 4 ''

gave me this error

''Wrong number of items passed 2, placement implies 1''

Maybe the error is trying to say that I can't fix a two dimensional array into a dataframe's column, but I don't know how to fix it. Please can someone be of help. Thank you.

@jdiego
Copy link

jdiego commented Jul 7, 2020

Hi @SallyAfua the correct code is the following:

movies['predicted_sentiment'] = nb.predict_proba(df_bows)[:, 1] * 8 - 4

Because the predict_proba returns an array-like of shape (n_samples, n_classes). So, this method returns the probability of the samples for each class in the model.

Best Regards

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

2 participants