microsoftml.get_sentiment: 감정 분석

사용

microsoftml.get_sentiment(cols: [str, dict, list], **kargs)

Description

자연어 텍스트에 점수를 매겨 감정이 긍정적일 확률을 평가합니다.

세부 정보

get_sentiment 변환은 자연 텍스트의 감정이 긍정적일 확률을 반환합니다. 현재는 영어만 지원합니다.

인수

cols

변환할 문자열 또는 변수 이름 목록. dict인 경우 이름은 만들 새 변수의 이름을 나타냅니다.

kargs

컴퓨팅 엔진으로 전송된 추가 인수입니다.

반환

변환을 정의하는 개체입니다.

추가 정보

featurize_text.

예제

'''
Example with get_sentiment and rx_logistic_regression.
'''
import numpy
import pandas
from microsoftml import rx_logistic_regression, rx_featurize, rx_predict, get_sentiment

# Create the data
customer_reviews = pandas.DataFrame(data=dict(review=[
            "I really did not like the taste of it",
            "It was surprisingly quite good!",
            "I will never ever ever go to that place again!!"]))
            
# Get the sentiment scores
sentiment_scores = rx_featurize(
    data=customer_reviews,
    ml_transforms=[get_sentiment(cols=dict(scores="review"))])
    
# Let's translate the score to something more meaningful
sentiment_scores["eval"] = sentiment_scores.scores.apply(
            lambda score: "AWESOMENESS" if score > 0.6 else "BLAH")
print(sentiment_scores)

출력:

Beginning processing data.
Rows Read: 3, Read Time: 0, Transform Time: 0
Beginning processing data.
Elapsed time: 00:00:02.4327924
Finished writing 3 rows.
Writing completed.
                                            review    scores         eval
0            I really did not like the taste of it  0.461790         BLAH
1                  It was surprisingly quite good!  0.960192  AWESOMENESS
2  I will never ever ever go to that place again!!  0.310344         BLAH