{"id":13689608,"url":"https://github.com/tidymodels/parsnip","last_synced_at":"2025-05-13T21:04:27.978Z","repository":{"id":28820549,"uuid":"113789613","full_name":"tidymodels/parsnip","owner":"tidymodels","description":"A tidy unified interface to models","archived":false,"fork":false,"pushed_at":"2025-04-22T18:13:01.000Z","size":31743,"stargazers_count":619,"open_issues_count":89,"forks_count":91,"subscribers_count":27,"default_branch":"main","last_synced_at":"2025-04-28T12:09:46.979Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://parsnip.tidymodels.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tidymodels.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-10T22:48:42.000Z","updated_at":"2025-04-24T19:53:29.000Z","dependencies_parsed_at":"2023-02-19T09:01:48.279Z","dependency_job_id":"b3715810-5bb1-45d8-b849-4dfa48e2a06f","html_url":"https://github.com/tidymodels/parsnip","commit_stats":{"total_commits":1668,"total_committers":51,"mean_commits":"32.705882352941174","dds":0.4982014388489209,"last_synced_commit":"a212f78f87d93d3f23cea2e8067f1c366bff8ea0"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fparsnip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fparsnip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fparsnip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fparsnip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidymodels","download_url":"https://codeload.github.com/tidymodels/parsnip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251311332,"owners_count":21569009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T15:01:55.320Z","updated_at":"2025-04-28T12:09:53.736Z","avatar_url":"https://github.com/tidymodels.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# parsnip \u003ca href=\"https://parsnip.tidymodels.org/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" alt=\"a drawing of a parsnip on a beige background\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/tidymodels/parsnip/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/parsnip/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/tidymodels/parsnip/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/parsnip?branch=main)\n[![CRAN status](https://www.r-pkg.org/badges/version/parsnip)](https://CRAN.R-project.org/package=parsnip)\n[![Downloads](https://cranlogs.r-pkg.org/badges/parsnip)](https://CRAN.R-project.org/package=parsnip)\n[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n\u003c!-- badges: end --\u003e\n\n## Introduction\n\nThe goal of parsnip is to provide a tidy, unified interface to models that can be used to try a range of models without getting bogged down in the syntactical minutiae of the underlying packages. \n\n## Installation\n\n```{r, eval = FALSE}\n# The easiest way to get parsnip is to install all of tidymodels:\ninstall.packages(\"tidymodels\")\n\n# Alternatively, install just parsnip:\ninstall.packages(\"parsnip\")\n\n# Or the development version from GitHub:\n# install.packages(\"pak\")\npak::pak(\"tidymodels/parsnip\")\n```\n\n\n## Getting started\n\nOne challenge with different modeling functions available in R _that do the same thing_ is that they can have different interfaces and arguments. For example, to fit a random forest regression model, we might have:\n\n```{r eval = FALSE}\n# From randomForest\nrf_1 \u003c- randomForest(\n  y ~ ., \n  data = dat, \n  mtry = 10, \n  ntree = 2000, \n  importance = TRUE\n)\n\n# From ranger\nrf_2 \u003c- ranger(\n  y ~ ., \n  data = dat, \n  mtry = 10, \n  num.trees = 2000, \n  importance = \"impurity\"\n)\n\n# From sparklyr\nrf_3 \u003c- ml_random_forest(\n  dat, \n  intercept = FALSE, \n  response = \"y\", \n  features = names(dat)[names(dat) != \"y\"], \n  col.sample.rate = 10,\n  num.trees = 2000\n)\n```\n\nNote that the model syntax can be very different and that the argument names (and formats) are also different. This is a pain if you switch between implementations. \n\nIn this example: \n\n* the **type** of model is \"random forest\", \n* the **mode** of the model is \"regression\" (as opposed to classification, etc), and \n* the computational **engine** is the name of the R package. \n\n\nThe goals of parsnip are to:\n\n* Separate the definition of a model from its evaluation.\n* Decouple the model specification from the implementation (whether the implementation is in R, spark, or something else). For example, the user would call `rand_forest` instead of `ranger::ranger` or other specific packages. \n* Harmonize argument names (e.g. `n.trees`, `ntrees`, `trees`) so that users only need to remember a single name. This will help _across_ model types too so that `trees` will be the same argument across random forest as well as boosting or bagging. \n\nUsing the example above, the parsnip approach would be:\n\n```{r}\nlibrary(parsnip)\n\nrand_forest(mtry = 10, trees = 2000) %\u003e%\n  set_engine(\"ranger\", importance = \"impurity\") %\u003e%\n  set_mode(\"regression\")\n```\n\nThe engine can be easily changed. To use Spark, the change is straightforward:\n\n```{r}\nrand_forest(mtry = 10, trees = 2000) %\u003e%\n  set_engine(\"spark\") %\u003e%\n  set_mode(\"regression\")\n```\n\nEither one of these model specifications can be fit in the same way:\n\n```{r}\nset.seed(192)\nrand_forest(mtry = 10, trees = 2000) %\u003e%\n  set_engine(\"ranger\", importance = \"impurity\") %\u003e%\n  set_mode(\"regression\") %\u003e%\n  fit(mpg ~ ., data = mtcars)\n```\n\nA list of all parsnip models across different CRAN packages can be found at https://www.tidymodels.org/find/parsnip.\n\n## Contributing\n\nThis project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n\n- For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on RStudio Community](https://forum.posit.co/new-topic?category_id=15\u0026tags=tidymodels,question).\n\n- If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/parsnip/issues).\n\n- Either way, learn how to create and share a [reprex](https://reprex.tidyverse.org/articles/articles/learn-reprex.html) (a minimal, reproducible example), to clearly communicate about your code.\n\n- Check out further details on [contributing guidelines for tidymodels packages](https://www.tidymodels.org/contribute/) and [how to get help](https://www.tidymodels.org/help/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fparsnip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidymodels%2Fparsnip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fparsnip/lists"}