Teradata Package for Python Function Reference - PCAEvaluator - 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
 
 
PCAEvaluator

 
Functions
       
PCAEvaluator(data, model, index_columns=None, accumulate=None)
DESCRIPTION:
    The function evaluates the PCA model created by PCA() VALIB function and generates
    an output XML string in result teradataml DataFrame.
    
PARAMETERS:
    data:
        Required Argument.
        Specifies the input data used to evaluate the PCA model.
        Types: teradataml DataFrame
    
    model:
        Required Argument.
        Specifies the teradataml DataFrame generated by VALIB PCA() function, containing
        the PCA model to evaluate.
        Types: teradataml DataFrame
    
    index_columns:
        Optional Argument.
        Specifies one or more different columns for the primary index of the result
        output DataFrame. By default, the primary index columns of the result output
        DataFrame are the primary index columns of the input DataFrame "data". In
        addition, the columns specified in this argument need to form a unique key for
        the result output DataFrame. Otherwise, there are more than one score for a
        given observation.
        Types: str OR list of Strings (str)
    
    accumulate:
        Optional Argument.
        Specifies one or more columns from the "data" DataFrame that can be passed to
        the result output DataFrame.
        Types: str OR list of Strings (str)
    
RETURNS:
    An instance of PCAEvaluator.
    Output teradataml DataFrames can be accessed using attribute references, such as 
    PCAEvalObj.<attribute_name>.
    Output teradataml DataFrame attribute name is: result
    
RAISES:
    TeradataMlException, TypeError, ValueError
    
EXAMPLES:
    # Notes:
    #   1. To execute Vantage Analytic Library functions,
    #       a. import "valib" object from teradataml.
    #       b. set 'configure.val_install_location' to the database name where Vantage 
    #          analytic library functions are installed.
    #   2. Datasets used in these examples can be loaded using Vantage Analytic Library 
    #      installer.
    
    # Import valib object from teradataml to execute this function.
    from teradataml import valib
 
    # Set the 'configure.val_install_location' variable.
    from teradataml import configure
    configure.val_install_location = "SYSLIB"
 
    # Create the required teradataml DataFrame.
    df = DataFrame("customer")
    print(df)
    
    # Run PCA() on columns "age", "income", "years_with_bank" and "nbr_children".
    pca_obj = valib.PCA(data=df,
                        columns=["age", "years_with_bank", "nbr_children", "income"])
    
    # Evaluate the PCA model created in the above step.
    obj = valib.PCAEvaluator(data=df,
                             model=pca_obj.result,
                             index_columns="cust_id",
                             accumulate=["age", "years_with_bank", "nbr_children"])
 
    # Print the results.
    print(obj.result)