run_performance {alookr}R Documentation

Apply calculate performance metrics for model evaluation

Description

Apply calculate performance metrics for binary classification model evaluation.

Usage

run_performance(model, actual = NULL)

Arguments

model

A model_df. results of predicted model that created by run_predict().

actual

factor. A data of target variable to evaluate the model. It supports factor that has binary class.

Details

run_performance() is performed in parallel when calculating the performance evaluation index. However, it is not supported in MS-Windows operating system and RStudio environment.

Value

model_df. results of predicted model. model_df is composed of tbl_df and contains the following variables.:

The performance metrics calculated are as follows.:

Examples


library(dplyr)

# Divide the train data set and the test data set.
sb <- rpart::kyphosis %>%
  split_by(Kyphosis)

# Extract the train data set from original data set.
train <- sb %>%
  extract_set(set = "train")

# Extract the test data set from original data set.
test <- sb %>%
  extract_set(set = "test")

# Sampling for unbalanced data set using SMOTE(synthetic minority over-sampling technique).
train <- sb %>%
  sampling_target(seed = 1234L, method = "ubSMOTE")

# Cleaning the set.
train <- train %>%
  cleanse

# Run the model fitting.
result <- run_models(.data = train, target = "Kyphosis", positive = "present")
result

# Predict the model. (Case 1)
pred <- run_predict(result, test)
pred

# Calculate performace metrics. (Case 1)
perf <- run_performance(pred)
perf
perf$performance

# Predict the model. (Case 2)
pred <- run_predict(result, test[, -1])
pred

# Calculate performace metrics. (Case 2)
perf <- run_performance(pred, pull(test[, 1]))
perf
perf$performance

# Convert to matrix for compare performace.
sapply(perf$performance, "c")



[Package alookr version 0.3.9 Index]