0

I have the following trained classifier:

classifier = nltk.NaiveBayesClassifier.train(features[:train_count])

When I try to use it to classify():

result = classifier.classify(feature)

and feature is ({'mean_compound': 1.0, 'mean_positive': 0.0, 'positives': 0}, ''), I hit the following error:

Traceback (most recent call last):
  File "/usr/src/Python/pAIthon/Nltk.py", line 240, in <module>
    CustomizeSentimentAnalysis()
  File "/usr/src/Python/pAIthon/Nltk.py", line 186, in CustomizeSentimentAnalysis
    result = classifier.classify(feature)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/lib/python3.12/site-packages/nltk/classify/naivebayes.py", line 89, in classify
    return self.prob_classify(featureset).max()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/lib/python3.12/site-packages/nltk/classify/naivebayes.py", line 95, in prob_classify
    featureset = featureset.copy()
                 ^^^^^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'copy'

What should be the input parameter to classify()?

1 Answer 1

0

Use the feature without the label: {'mean_compound': 1.0, 'mean_positive': 0.0, 'positives': 0}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.