анализ настроений прогнозирования с использованием Python - PullRequest
0 голосов
/ 20 октября 2018

У меня есть мой код, который работает в строке, как показано ниже, используя библиотеку Scikit Learn. Наивный байес

bow_test = countVector.transform (['the phone bad ','the phone is bad but delivery very good','very nice but slow delivery'])
prediction['Multinomial'] = NB.predict(bow_test)
print ( prediction['Multinomial'])

вывод

['negative' 'positive' 'positive']

, но при тестировании с пандами не работает

c = 0
i = 0
for i in sentimentLa['review']:
    print(i)
    c+= 1   
    bow_comment = countVector.transform (['i'])
    prediction['Multinomial'] = NB.predict(bow_comment)
    score =  (round(NB.predict_proba(bow_comment)[0][1],5))
    sentimentLa.loc[c-1, 'sentiment'] = prediction['Multinomial']
    sentimentLa.loc[c-1, 'score'] = score
    print(prediction['Multinomial'])
    print(score)

Первый отзыв должен быть обнаружен отрицательно, и оценка должна быть другой

      review                                             sentiment   score
0   Sad to say the iPhone keeps rebooting even aft...   [positive]  0.74839
1   great product, downside is the shipping with n...   [positive]  0.74839
2   Very quick delivery! Under 24 hours! Product r...   [positive]  0.74839

Любая помощь с быть оцененным:)

...