Tidymodels is an R framework for machine learning modelling inspired by the functional programming style adopted by the tidyverse. In contrast with the popular caret package, Tidymodels is an entire framework composed of a collection of packages. Conversely, caret is a single package containing many machine learning methods and tools.
Recipes
The purpose of Tidymodels recipes to create reproducible data preprocessing pipelines. A recipe is composed of a sequence of data preprocessing steps.
One purpose of Tidymodels is to provide a layer of abstraction between different packages. For instance, there are several packages such as randomForest and ranger that implement the random forest algorithm. With Tidymodels, we can easily switch between these different implementations and specify whether we are performing regression or classification.
Next, we define a Tidymodel workflow. This allows us to combine the above preprocessing steps with a random forest regressor. Also note that Tidymodels encourages a high degree of modularity. We can save complex preprocessing recipes, and easily switch between different models.
We will next demonstrate how to integrate Tidymodels with MLFlow.
Registering Models
We will first create a new model in the model registry.
client =mlflow_client()tryCatch(expr = {mlflow_delete_registered_model("sw_rf", client = client)},error =function(x) {})mlflow_create_registered_model("sw_rf", client = client, description ="Perform predictions for Star Wars characters using Random Forest.")
$name
[1] "sw_rf"
$creation_timestamp
[1] 1.668548e+12
$last_updated_timestamp
[1] 1.668548e+12
$description
[1] "Perform predictions for Star Wars characters using Random Forest."
We will next execute an MLFlow run.
MLFlow Run
Metric Tracking
We will log the metrics and parameters for the random forest run.