model_metrics: Calculate Model Metrics

View source: R/metrics.R

model_metricsR Documentation

Calculate Model Metrics

Description

Calculates a variety of standard model metrics, given the truth and predicted values as vectors.

Usage

model_metrics(truth, predicted, categorical = FALSE)

Arguments

truth

A vector - the true outcome values.

predicted

A vector - the predicted outcome values.

categorical

A logical - Is the true outcome a categorical response variable? This function only handles the binary case where truth is a factor with levels 0 and 1.

Value

A tibble with calculated model metrics

Examples

# Continuous outcome
mtcarslm <- lm(mpg ~ ., mtcars)
model_metrics(mtcars$mpg, mtcarslm$fitted.values)

# Binary outcome
iris$isSetosa <- factor(as.integer(iris$Species == "setosa"))
irisglm <- glm(isSetosa ~ Sepal.Length, iris, family = "binomial")
model_metrics(iris$isSetosa, irisglm$fitted.values, TRUE)


dmolitor/dmolitorUtils documentation built on Sept. 24, 2022, 6 a.m.