df_r2: Coefficient of Determination (R^2) (computation function, any...

Description Usage Arguments Value Examples

Description

This function computes the Coefficient of Determination loss (R^2) provided preds and labels, while handling multiclass problems (mean).

Usage

1
df_r2(preds, labels)

Arguments

preds

The predictions.

labels

The labels.

Value

The Coefficient of Determination.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(data.table)

# Regression problem
my_preds <- dnorm(rnorm(n = 9*6*10))
my_labels <- runif(n = 9*6*10)
df_r2(my_preds, my_labels)

# Binary classification problem
my_preds <- dnorm(rnorm(n = 9*6*10))
my_labels <- as.numeric(runif(n = 9*6*10) >= 0.5)
df_r2(my_preds, my_labels)

# Multiclass classification problem
my_preds <- data.table(matrix(dnorm(rnorm(n = 9*6*10)), nrow = 9*10))
my_labels <- rep(c(1, 2, 3, 4, 5, 1, 0, 2, 3), 10)
df_r2(my_preds, my_labels)

Laurae2/Laurae documentation built on May 8, 2019, 7:59 p.m.