Teradata Python Package Function Reference - ConfusionMatrix - 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.ConfusionMatrix = class ConfusionMatrix(builtins.object)
     Methods defined here:
__init__(self, data=None, reference=None, prediction=None, classes=None, prevalence=None, data_sequence_column=None)
DESCRIPTION:
    The ConfusionMatrix function shows how often a classification 
    algorithm correctly classifies items. The function takes an input 
    teradataml data frame that includes two columns one containing the
    observed class of an item and the other containing the class
    predicted by the algorithm and outputs three tables mentioned under RETURNS.
 
 
PARAMETERS:
    data:
        Required Argument.
        The input teradataml data frame of ConfusionMatrix function
 
    reference:
        Required Argument.
        Specifies the name of the input column that contains the observed
        class.
        Types: str
 
    prediction:
        Required Argument.
        Specifies the name of the input column that contains the predicted
        class.
        Types: str
 
    classes:
        Optional Argument.
        Specifies the classes to output in output_table.
        Types: str OR list of Strings (str)
 
    prevalence:
        Optional Argument.
        Specifies the prevalences for the classes to output in
        output_table_3. Therefore, if you specify prevalence, then you must
        also specify classes, and for every class, you must specify a
        prevalence.
        Types: float OR list of floats
 
    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 ConfusionMatrix.
    Output teradataml DataFrames can be accessed using attribute
    references, such as ConfusionMatrixObj.<attribute_name>.
    Output teradataml DataFrame attribute names are:
        1. counttable
        2. stattable
        3. accuracytable
        4. output
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load the data to run the example.
    load_example_data("confusionmatrix", "iris_category_expect_predict")
 
    # Create teradataml Dataframe.
    iris_category_expect_predict = DataFrame.from_table("iris_category_expect_predict")
 
    # Example
    confusion_matrix_output = ConfusionMatrix(data=iris_category_expect_predict,
                                              reference='expected_value',
                                              prediction='predicted_value',
                                              classes='versicolor',
                                              prevalence=0.5,
                                              data_sequence_column='id'
                                              )
 
    # Print the result teradataml DataFrame
    print(confusion_matrix_output.counttable)
    print(confusion_matrix_output.stattable)
    print(confusion_matrix_output.accuracytable)
    print(confusion_matrix_output.output)
__repr__(self)
Returns the string representation for a ConfusionMatrix class instance.