{"id":19253610,"url":"https://github.com/tidymodels/finetune","last_synced_at":"2025-10-25T10:11:14.573Z","repository":{"id":42980658,"uuid":"277178611","full_name":"tidymodels/finetune","owner":"tidymodels","description":"Additional functions for model tuning","archived":false,"fork":false,"pushed_at":"2024-11-12T14:59:20.000Z","size":8236,"stargazers_count":62,"open_issues_count":10,"forks_count":8,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-31T15:26:39.923Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://finetune.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":null,"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":"2020-07-04T20:12:07.000Z","updated_at":"2024-08-15T21:12:45.000Z","dependencies_parsed_at":"2023-11-14T02:31:31.396Z","dependency_job_id":"9e266de0-d203-47df-8f51-7285e71c07de","html_url":"https://github.com/tidymodels/finetune","commit_stats":{"total_commits":155,"total_committers":9,"mean_commits":17.22222222222222,"dds":"0.21935483870967742","last_synced_commit":"cecd5ebf3a650800341488cfd604d301f309b95f"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Ffinetune","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Ffinetune/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Ffinetune/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Ffinetune/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidymodels","download_url":"https://codeload.github.com/tidymodels/finetune/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"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-11-09T18:32:08.487Z","updated_at":"2025-10-25T10:11:14.567Z","avatar_url":"https://github.com/tidymodels.png","language":"R","funding_links":[],"categories":[],"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# finetune \u003ca href='https://finetune.tidymodels.org'\u003e\u003cimg src='man/figures/logo.png' align=\"right\" height=\"138\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/tidymodels/finetune/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/finetune/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/tidymodels/finetune/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/finetune?branch=main)\n[![Lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![Codecov test coverage](https://codecov.io/gh/tidymodels/finetune/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/finetune)\n\u003c!-- badges: end --\u003e\n\n`finetune` contains some extra functions for model tuning that extend what is currently in the `tune` package. You can install the CRAN version of the package with the following code:\n\n```{r, eval = FALSE}\ninstall.packages(\"finetune\")\n```\n\nTo install the development version of the package, run:\n\n```{r, eval = FALSE}\n# install.packages(\"pak\")\npak::pak(\"tidymodels/finetune\")\n```\n\nThere are two main sets of tools in the package: _simulated annealing_ and _racing_. \n\nTuning via _simulated annealing_ optimization is an iterative search tool for finding good values: \n\n```{r load, include=FALSE}\nlibrary(tidymodels)\nlibrary(finetune)\nlibrary(discrim)\nlibrary(rlang)\nlibrary(MASS)\n```\n```{r sa}\nlibrary(tidymodels)\nlibrary(finetune)\n\n# Syntax very similar to `tune_grid()` or `tune_bayes()`: \n\n## -----------------------------------------------------------------------------\n\ndata(two_class_dat, package = \"modeldata\")\n\nset.seed(1)\nrs \u003c- bootstraps(two_class_dat, times = 10) # more resamples usually needed\n\n# Optimize a regularized discriminant analysis model\nlibrary(discrim)\nrda_spec \u003c-\n  discrim_regularized(frac_common_cov = tune(), frac_identity = tune()) |\u003e\n  set_engine(\"klaR\")\n\n## -----------------------------------------------------------------------------\n\nset.seed(2)\nsa_res \u003c- \n  rda_spec |\u003e \n  tune_sim_anneal(Class ~ ., resamples = rs, iter = 20, initial = 4)\nshow_best(sa_res, metric = \"roc_auc\", n = 2)\n```\n\nThe second set of methods are for _racing_. We start off by doing a small set of resamples for all of the grid points, then statistically testing to see which ones should be dropped or investigated more. The two methods here are based on those should in [Kuhn (2014)](https://arxiv.org/abs/1405.6974). \n\nFor example, using an ANOVA-type analysis to filter out parameter combinations:\n\n```{r race}\nset.seed(3)\ngrid \u003c-\n  rda_spec |\u003e\n  extract_parameter_set_dials() |\u003e\n  grid_max_entropy(size = 20)\n\nctrl \u003c- control_race(verbose_elim = TRUE)\n\nset.seed(4)\ngrid_anova \u003c- \n  rda_spec |\u003e \n  tune_race_anova(Class ~ ., resamples = rs, grid = grid, control = ctrl)\n\nshow_best(grid_anova, metric = \"roc_auc\", n = 2)\n```\n\n`tune_race_win_loss()` can also be used. It treats the tuning parameters as sports teams in a tournament and computed win/loss statistics. \n\n\n```{r race-wl}\nset.seed(4)\ngrid_win_loss\u003c- \n  rda_spec |\u003e \n  tune_race_win_loss(Class ~ ., resamples = rs, grid = grid, control = ctrl)\n\nshow_best(grid_win_loss, metric = \"roc_auc\", n = 2)\n```\n\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 Posit 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/usemodels/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%2Ffinetune","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidymodels%2Ffinetune","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Ffinetune/lists"}