tidymodels recipes

repository·main·Indexed 20 days ago

https://github.com/tidymodels/recipes

A part of the tidymodels ecosystem providing a pipeable, dplyr-like interface for feature engineering and data preprocessing. It allows users to define sequences of transformations via recipe() objects and step_* functions to prepare data for machine learning models, serving as a flexible alternative to R formulas or model.matrix.

Tokens
462
Snippets
2
Records
2
Agent score
20%

What's inside recipes

  1. What is recipes and how to use it for feature engineering

    main

    The recipes package provides a dplyr-like, pipeable interface for defining sequences of feature engineering steps. It is used to prepare data for modeling by creating preprocessing specifications (recipes) that can be applied to datasets. This is an alternative to using R formulas or model.matrix for creating design matrices, offering more flexibility for complex preprocessing workflows.

    To use recipes, you define a recipe() object specifying the formula and the data, then chain preprocessing steps (starting with step_*) using the pipe operator.

    library(recipes)
    data(ad_data, package = "modeldata")
    
    ad_rec <- recipe(Class ~ tau + VEGF, data = ad_data) |>
      step_normalize(all_numeric_predictors())
    
    ad_rec
  2. Install recipes

    main

    You can install recipes via CRAN or the development version from GitHub.

    To install the full tidymodels suite (recommended for most users):

    install.packages("tidymodels")

    To install only the recipes package:

    install.packages("recipes")

    To install the development version from GitHub using pak:

    # install.packages("pak")
    pak::pak("tidymodels/recipes")
    # The easiest way to get recipes is to install all of tidymodels:
    install.packages("tidymodels")
    
    # Alternatively, install just recipes:
    install.packages("recipes")
    
    # Or the development version from GitHub:
    # install.packages("pak")
    pak::pak("tidymodels/recipes")