Learn R Programming

MLmorph (version 0.1.1)

create_morphospace: Create a morphospace of predictor combinations with class probabilities

Description

Create a morphospace of predictor combinations with class probabilities

Usage

create_morphospace(the_data, model, shiny = FALSE)

Value

A list with components:

  • morphospace: data frame with all predictor combinations, class label column (named as the dependent), calculated (probability), and purely_simulated flag.

  • dependent: character scalar with the outcome name.

  • independent: character vector of predictor names.

  • all_vars: character vector c(independent, dependent).

  • purely_simulated: logical vector aligned with morphospace.

Arguments

the_data

A data.frame used to derive unique values of predictors.

model

A classification model fitted via a formula interface that supports predict(model, newdata, type = "prob") (e.g., from create_rf_model).

shiny

Logical; if TRUE, compute predictions in batches with shiny progress. Default FALSE.

Examples

Run this code
n  <- 60
y  <- factor(sample(letters[1:3], n, TRUE))
x1 <- factorize_numeric_vector(runif(n, 10, 20), breaks_no = 3)
x2 <- factorize_numeric_vector(runif(n,  1,  2), breaks_no = 3)
df <- data.frame(y, x1, x2)
fit <- create_rf_model(df, dependent = "y", ntree = 50)$model
ms  <- create_morphospace(df, fit)
names(ms)

Run the code above in your browser using DataLab