Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Usage
microsoftml.get_sentiment(cols: [str, dict, list], **kargs)
Descrzione
Valuta il testo in linguaggio naturale e valuta la probabilità che i sentimenti siano positivi.
dettagli
La get_sentiment trasformata restituisce la probabilità che il sentimento di un testo naturale sia positivo. Attualmente supporta solo la lingua inglese.
Arguments
Cols
Una stringa di caratteri o una lista di nomi di variabili da trasformare. Se dict, i nomi rappresentano i nomi delle nuove variabili da creare.
karg
Argomenti aggiuntivi inviati al motore di calcolo.
Returns
Oggetto che definisce la trasformazione.
Esempio
'''
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