Learn R Programming

Laurae (version 0.0.0.9001)

df_r: Pearson Coefficient of Correlation (R) (computation function, any size)

Description

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

Usage

df_r(preds, labels)

Arguments

preds
The predictions.
labels
The labels.

Value

The Pearson Coefficient of Correlation.

Examples

Run this code
library(data.table)

# Regression problem
my_preds <- dnorm(rnorm(n = 9*6*10))
my_labels <- runif(n = 9*6*10)
df_r(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_r(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_r(my_preds, my_labels)

Run the code above in your browser using DataLab