hanaml.Confusion.matrix {hana.ml.r}R Documentation

Confusion Matrix

Description

Compute confusion matrix to evaluate the accuracy of a classification.

Usage

hanaml.Confusion.matrix(conn.context,
                       data,
                       key,
                       label.true = NULL,
                       label.pred = NULL,
                       beta = NULL)

Arguments

conn.context

ConnectionContext
The connection to the SAP HANA system.

data

DataFrame
DataFrame containing the data.

key

character
Name of the ID column.

label.true

character, optional
Name of the original label column.
If not given, defaults to the second columm.

label.pred

character, optional)
Name of the predicted label column.
If not given, defaults to the third columm.

beta

double, optional
Parameter used to compute the F-Beta score.
Defaults to 1.

Value

Examples

## Not run: 
DataFrame df to calculate the confusion matrix:
>df$Collect()
      ID  ORIGINAL  PREDICT
   0   1         1        1
   1   2         1        1
   2   3         1        1
   3   4         1        2
   4   5         1        1
   5   6         2        2
   6   7         2        1
   7   8         2        2
   8   9         2        2
   9  10         2        2

Calculate the confusion matrix:

> cm, cr <- hanaml.Confusion.matrix(connection.context = conn, data = df,
                                   key = "ID", label.true = "ORIGINAL",
                                   label.pred = "PREDICT")

Return:

> cm$Collect()
      ORIGINAL  PREDICT  COUNT
   0         1        1      4
   1         1        2      1
   2         2        1      1
   3         2        2      4

> cr$Collect()
     CLASS  RECALL  PRECISION  F_MEASURE  SUPPORT
   0     1     0.8        0.8        0.8        5
   1     2     0.8        0.8        0.8        5

## End(Not run)

[Package hana.ml.r version 1.0.8 Index]