So i categorize the sentiment scores by using our basic else if elif. but when sentences go above 400 or maybe even above 3k-4k. This starts to take a lot of time. So can you please suggest me something that does the same job but way faster?
for i in tqdm(range(len)):
sent = dff['compound'][i]
if(sent<=5 and sent>=3.0):
dff['Sentiment'][i]='V.Positive'
elif (sent<3.0 and sent>0.5):
dff['Sentiment'][i]='Positive'
elif (sent<0.5 and sent>-0.5):
dff['Sentiment'][i]='Neutral'
elif (sent<-0.5 and sent>=-3.0):
dff['Sentiment'][i]='Negative'
else:
dff['Sentiment'][i]='V.Negative'
PS - I use TQDM library as a to see progress bar during execution. Any alternatives to this code ? or maybe optimize this code itself? Regardless it has to classify.
Aucun commentaire:
Enregistrer un commentaire