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

Sentiment Analysis very slow in mac #1534

Closed
janeshdev opened this issue Apr 21, 2020 · 7 comments
Closed

Sentiment Analysis very slow in mac #1534

janeshdev opened this issue Apr 21, 2020 · 7 comments
Labels
question Further information is requested

Comments

@janeshdev
Copy link

janeshdev commented Apr 21, 2020

Hi, I am using flair for sentiment analysis using en-sentiment text classifier and I am running for 2000 sentences and it's very slow. The code is running for more than 3 hours now and still not finished. The code I am using is as follows:

from flair.models import TextClassifier
from flair.data import Sentence
classifier = TextClassifier.load('en-sentiment')

# Create a function 
def sentiment_analysis(text):
    tt = Sentence(text)
    classifier.predict(tt)
    if tt.labels[0].value == 'POSITIVE':
        multiplier = 1
    else: 
        multiplier = -1  
    sentiment = multiplier * tt.labels[0].score 
    return(';;'.join([tt.labels[0].value, repr(sentiment)]))

df['sentiment'] = df.customer_comments.apply(sentiment_analysis).str.split(";;")

Any tips or ideas to speed up this implementation?

Also can you please let me know how is the sentiment calculated in en-sentiment ? I am using this to find sentiment for customer reviews. Would it make sense to use on customer reviews?

Thanks for the wonderful package.

@janeshdev janeshdev added the question Further information is requested label Apr 21, 2020
@alanakbik
Copy link
Collaborator

Hello @janeshdev how long are your documents and do you have a GPU?

@alanakbik
Copy link
Collaborator

The current sentiment model is trained using English movie reviews, so it will work best for such text. We are in the process of training better sentiment models over a mix of domains, which should be added very soon. We can add a 'normal' and a 'fast' variant for CPU-only setups.

@janeshdev
Copy link
Author

Hello @janeshdev how long are your documents and do you have a GPU?

Hi I don't have a GPU and there are approximately 35000 comments that I was trying to use Sentiment analysis on. Do you have a list of sentiment models that are on pipeline? I would love to see sentiment analysis based on customer comments on service / product etc.

@alanakbik
Copy link
Collaborator

Yes, I am currently training models over the datasets as described in #1545 which includes a lot of product reviews, tweets and other data. I will push them very soon and let you know!

@alanakbik
Copy link
Collaborator

@janeshdev I am currently training sentiment models (see #1545) that includes Amazon reviews across many categories. They will be made available soon!

@janeshdev
Copy link
Author

Hi @alanakbik are the new sentiment models ready to use?

@alanakbik
Copy link
Collaborator

Just merged #1613. On master branch, two new (much better) models are now available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants