Teradata Package for R Function Reference | 17.00 - ConfusionMatrix - Teradata Package for R - Look here for syntax, methods and examples for the functions included in the Teradata Package for R.

Teradata® Package for R Function Reference

Product
Teradata Package for R
Release Number
17.00
Published
July 2021
Language
English (United States)
Last Update
2023-08-08
dita:id
B700-4007
NMT
no
Product Category
Teradata Vantage
ConfusionMatrix

Description

The ConfusionMatrix function shows how often a classification algorithm correctly classifies items. The function takes an input tbl_teradata 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 tbl_teradata objects.

Usage

  td_confusion_matrix_mle (
      data = NULL,
      reference = NULL,
      prediction = NULL,
      classes = NULL,
      prevalence = NULL,
      data.sequence.column = NULL
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata that is used to generate Confusion Matrix.

reference

Required Argument.
Specifies the name of the input column that contains the observed class.
Types: character

prediction

Required Argument.
Specifies the name of the input column that contains the predicted class.
Types: character

classes

Optional Argument.
Specifies the classes to output in output tbl_teradata.
Types: character OR vector of characters

prevalence

Optional Argument.
Specifies the prevalences for the classes to output in third output tbl_teradata which contains statistics for each class. Therefore, if you specify prevalence, then you must also specify classes, and for every class, you must specify a prevalence.
Types: numeric OR vector of numerics

data.sequence.column

Optional Argument.
Specifies the vector 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: character OR vector of Strings (character)

Value

Function returns an object of class "td_confusion_matrix_mle" which is a named list containing objects of class "tbl_teradata".
Named list members can be referenced directly with the "$" operator using following names:

  1. counttable

  2. stattable

  3. accuracytable

  4. output

Examples

  
    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("confusionmatrix_example", "iris_category_expect_predict")

    # Create object(s) of class "tbl_teradata".
    iris_category_expect_predict <- tbl(con, "iris_category_expect_predict")

    # Example 1 -
    confusion_matrix_out <- td_confusion_matrix_mle(data = iris_category_expect_predict,
                                  reference = "expected_value",
                                  prediction = "predicted_value"
                                  )