model_gen: Generate a machine learning model

View source: R/model_gen.R

model_genR Documentation

Generate a machine learning model

Description

This function takes in all the data needed to produce machine learning model. Inputs are handed to a RMD report/ script. Outputs include the markdown report, the cross validation object, and a binary model (RDS) that can then be used to predict on new data.

Usage

model_gen(
  traindat,
  target,
  mType = "rF",
  outDir = ".",
  trees = 500,
  rseed = NA
)

Arguments

traindat

Is a dataframe that contains the model training data. The reponse variable should be one of the columns.

target

The name of the response variable in the traindat data frame.

mType

rF for a ranger random forest; tidy for a tidymodels version using ranger; esb for an ensemble of ranger, glmnet, xgboost, and 'nnTrain“; others to be added. This acts as a suffix for which model_gen_XXX.Rmd to call.

outDir

Highly recommended to be set as an absolute directory. This defaults to the project's root directory OR where the RMD script is saved. Additional products generated from the associated 'model_gen_XXX.Rmd“ markdown scripts will also be saved to this dir.

trees

A random forest parameter for the number of trees to use.

rseed

Optional random number seed.

Examples

dat <- read.csv("e:/workspace/2020/PEM/ALRF_PEMv2/dev/modDat.csv",
               stringsAsFactors = TRUE)


model_gen(traindat = dat,
          target = "SiteSeries",
          outDir = "e:/tmp/model_gen_test",
          mType = "rF",
          trees = 500,
          rseed = 456)

ColinChisholm/pemgeneratr documentation built on March 14, 2023, 10:47 p.m.