Usage
microsoftml.get_sentiment(cols: [str, dict, list], **kargs)
Description
自然言語のテキストを評価し、感情が肯定的である確率を評価します。
詳細情報
get_sentiment変換は自然のテキストの感情が正である確率を返します。 現在は英語のみに対応しています。
引数
cols
変換する変数名の文字列またはリスト。
dictの場合、その名前は新たに作成される変数の名前を表します。
kargs
コンピューティング エンジンに送信される追加の引数。
返品
変換を定義するオブジェクト。
例
'''
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)
Output:
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