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

Teradata® R Package Function Reference

Product
Teradata R Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-28
dita:id
B700-4007
lifecycle
previous
Product Category
Teradata Vantage

Description

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

Usage

  td_confusion_matrix_mle (
      data = NULL,
      reference = NULL,
      prediction = NULL,
      classes = NULL,
      prevalence = NULL
  )

Arguments

data

Required Argument.
Specifies the input table of ConfusionMatrix function.

reference

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

prediction

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

classes

Optional Argument.
Specifies the classes to output in output table.

prevalence

Optional Argument.
Specifies the prevalences for the classes to output in third output table 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.

Value

Function returns an object of class "td_confusion_matrix_mle" which is a named list containing Teradata tbl objects.
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 remote tibble objects.
    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"
                                  )