Teradata Python Package Function Reference - SentimentTrainer - Teradata Python Package - Look here for syntax, methods and examples for the functions included in the Teradata Python Package.

Teradata® Python Package Function Reference

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-07-17
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.mle.SentimentTrainer = class SentimentTrainer(builtins.object)
     Methods defined here:
__init__(self, data=None, text_column=None, sentiment_column=None, language='en', model_file=None, data_sequence_column=None)
DESCRIPTION:
    The SentimentTrainer function trains a model. It takes training
    documents and outputs a maximum entropy classification model, which
    it installs on the ML Engine. For information about maximum entropy,
    see http://en.wikipedia.org/wiki/Maximum entropy method.
 
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the name of the teradataml DataFrame that contains the
        training data.
 
    text_column:
        Required Argument.
        Specifies the name of the input teradataml DataFrame column that
        contains the training data.
        Types: str
 
    sentiment_column:
        Required Argument.
        Specifies the name of the input teradataml DataFrame column that
        contains the sentiment values, which are "POS" (positive), "NEG"
        (negative), and "NEU" (neutral).
        Types: str
 
    language:
        Optional Argument.
        Specifies the language of the training data: "en" (English), "zh_CN"
        (Simplified Chinese), "zh_TW" (Traditional Chinese).
        Default Value: "en"
        Permitted Values: en, zh_CN, zh_TW
        Types: str
 
    model_file:
        Required Argument.
        Specifies the name of the file to which the function outputs the
        model.
        Types: str
 
    data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "data". The argument is used to ensure
        deterministic results for functions which produce results that vary
        from run to run.
        Types: str OR list of Strings (str)
 
RETURNS:
    Instance of SentimentTrainer.
    Output teradataml DataFrames can be accessed using attribute
    references, such as SentimentTrainerObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load example data.
    load_example_data("sentimenttrainer", "sentiment_train")
 
    # Create teradataml DataFrame objects.
    # The sample dataset contains collection of user reviews for different products.
    sentiment_train = DataFrame.from_table("sentiment_train")
 
    # Example 1 - Build a model and output a maximum entropy classification
    # model to a binary file
    SentimentTrainer_out = SentimentTrainer(data = sentiment_train,
                                            text_column = "review",
                                            sentiment_column = "category",
                                            model_file = "sentimentmodel1.bin"
                                            )
 
    # Print the results.
    print(SentimentTrainer_out)
__repr__(self)
Returns the string representation for a SentimentTrainer class instance.