0

Hi is there a way I can display just the tag_name using MonkeyLearn instead of a full text? Here is the code

from monkeylearn import MonkeyLearn
ml = MonkeyLearn('xxxx')
classifier = ['text']
model_id = 'xxxx'
response = ml.classifiers.classify(model_id, data)
print(response.body)

I have tried using print(response.classifications) but I get and error saying that

'MonkeyLearnResponse' object has no attribute 'classifications'

1 Answers1

1

The error is likely due to the wrong use of the library. I believe it's on this -ml.classifiers.classify(model_id, data) line where it doesn't return the correct object.

Sample code from the docs

from monkeylearn.exceptions import PlanQueryLimitError

data = ['Text to classify'] * 300
batch_size = 200

try:
    response = ml.classifiers.classify('[MODEL_ID]', data, batch_size=batch_size)
except PlanQueryLimitError as e:

As you can see, try to pass your model_id as an array value rather than a string and ensure your data variable is correct.

AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35