Description Usage Arguments Details Value Examples
Fits a MARS regression model.
1 2 3 4 5 6 7 8 9 | marsRegress(
response = response,
recipe = rec,
folds = folds,
train = train_df,
test = test_df,
gridNumber = 10,
evalMetric = "rmse"
)
|
response |
Character. The variable that is the response for analysis. |
recipe |
A recipes::recipe object. |
folds |
A rsample::vfolds_cv object. |
train |
Data frame/tibble. The training data set. |
test |
Data frame/tibble. The testing data set. |
gridNumber |
Numeric. The size of the grid to tune on. Default is 15. |
evalMetric |
Character. The regression metric you want to evaluate the model's accuracy on. Default is RMSE. Can choose from the following:
|
Note - Tunes the following parameters:
num_terms: The number of features that will be retained in the final model.
prod_degree: The highest possible degree of interaction between features. A value of 1 indicates an additive model while a value of 2 allows, but does not guarantee, two-way interactions between features.
prune_method: The type of pruning. Possible values are listed in ?earth.
A list with the following elements:
Training set predictions
Training set evaluation on RMSE and MAE
Testing set predictions
Testing set evaluation on RMSE and MAE
Tuned model object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | library(easytidymodels)
library(dplyr)
library(recipes)
utils::data(penguins, package = "modeldata")
#Define your response variable and formula object here
resp <- "bill_length_mm"
formula <- stats::as.formula(paste(resp, ".", sep="~"))
#Split data into training and testing sets
split <- trainTestSplit(penguins, responseVar = resp)
#Create recipe for feature engineering for dataset, varies based on data working with
rec <- recipe(formula, split$train) %>% prep()
train_df <- bake(rec, split$train)
test_df <- bake(rec, split$test)
folds <- cvFolds(train_df)
#Fit a MARS regression object (commented out only due to long run time)
#marsReg <- marsRegress(recipe = rec, response = resp,
#folds = folds, train = train_df, test = test_df, evalMetric = "rmse")
#Visualize training data and its predictions
#marsReg$trainPred %>% select(.pred, !!resp)
#View how model metrics for RMSE, R-Squared, and MAE look for training data
#marsReg$trainScore
#Visualize testing data and its predictions
#marsReg$testPred %>% select(.pred, !!resp)
#View how model metrics for RMSE, R-Squared, and MAE look for testing data
#marsReg$testScore
#See the final model chosen for MARS based on optimizing for your chosen evaluation metric
#marsReg$final
#See how model fit looks based on another evaluation metric
#marsReg$tune %>% tune::show_best("mae")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.