Teradata Package for Python Function Reference - NEREvaluator - 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.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.mle.NEREvaluator = class NEREvaluator(builtins.object)
     Methods defined here:
__init__(self, data=None, text_coloumn=None, model=None, language='en', data_sequence_column=None, data_order_column=None)
DESCRIPTION:
    The NEREvaluator function evaluates a CRF model (output by the 
    function NERTrainer).
    Note:
        NEREvaluator uses below files that are preinstalled on the ML Engine:
            * ner_model_1.0_reuters_en_all_141011.bin
            * template_1.txt
 
 
PARAMETERS:
    data:
        Required Argument.
        Specifies an input teradataml DataFrame containing input data.
    
    data_order_column:
        Optional Argument.
        Specifies Order By columns for data.
        Values to this argument can be provided as a list, if multiple 
        columns are used for ordering.
        Types: str OR list of Strings (str)
    
    text_coloumn:
        Required Argument.
        Specifies the name of the input teradataml DataFrame column that 
        contains the text to analyze.
        Types: str
    
    model:
        Required Argument.
        Specifies the CRF model file (binary file) to evaluate, generated by
        "NERTrainer" function. If you specified the ExtractorJAR argument in the
        NERTrainer call that generated model_file, then you must specify
        the same jar_file in this argument. You must install model_file and 
        jar_file in ML Engine under the user search path before calling
        the NEREvaluator function.
        Note:
            1. The names of model_file and jar_file are case-sensitive.
            2. For JAR files installation instructions, see Teradata Vantage User Guide.
        Types: str
    
    language:
        Optional Argument.
        Specifies the language of the input text:
            * en - English
            * zh_CN - Simplified Chinese
            * zh_TW - Traditional Chinese
        Default Value: "en"
        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 NEREvaluator.
    Output teradataml DataFrames can be accessed using attribute 
    references, such as NEREvaluatorObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Before running NEREvaluator, run NERTrainer to generate model file.
    # Load the data to run the NERTrainer example.
    load_example_data("nertrainer","ner_sports_train")
 
    # Create teradataml DataFrame object.
    ner_sports_train = DataFrame.from_table("ner_sports_train")
 
    # Run the train function to generate model file for NEREvaluator function.
    nertrainer_train = NERTrainer(data=ner_sports_train,
                                  text_coloumn='content',
                                  model_file='ner_model.bin',
                                  feature_template='template_1.txt'
                                  )
    # Print the result DataFrame.
    print(nertrainer_train.result)
 
    # NEREvaluator
    # Example - Run evaluator function to evaluate a CRF model (generated by NERTrainer)
    # Load the data to run the example.
    load_example_data("nerevaluator", "ner_sports_test2")
 
    # Create teradataml DataFrame object.
    ner_sports_test2 = DataFrame.from_table("ner_sports_test2")
 
    # Run the evaluator function using rules entity.
    nerevaluator_out = NEREvaluator(data=ner_sports_test2,
                                    text_coloumn='content',
                                    model='ner_model.bin',
                                    language='en',
                                    data_sequence_column='id'
                                    )
 
    # Print the result DataFrame.
    print(nerevaluator_out.result)
__repr__(self)
Returns the string representation for a NEREvaluator 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.