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

Teradata® Package for Python Function Reference

Product
Teradata Package for Python
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
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, punctuation=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)
 
    punctuation:
        Optional Argument.
        Specifies a regular expression that represents the punctuation
        characters to remove from the input text.
        Note:
            "punctuation" argument support is only available when teradataml
            is connected to Vantage 1.3 version.
        Types: 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, TypeError, ValueError
 
 
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.
get_build_time(self)
Function to return the build time of the algorithm in seconds.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
get_prediction_type(self)
Function to return the Prediction type of the algorithm.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
get_target_column(self)
Function to return the Target Column of the algorithm.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
show_query(self)
Function to return the underlying SQL query.
When model object is created using retrieve_model(), then None is returned.