{"id":19253606,"url":"https://github.com/tidymodels/desirability2","last_synced_at":"2025-04-21T14:32:10.584Z","repository":{"id":46483476,"uuid":"396120776","full_name":"tidymodels/desirability2","owner":"tidymodels","description":"Desirability Functions for Multiparameter Optimization","archived":false,"fork":false,"pushed_at":"2024-10-23T15:09:54.000Z","size":2754,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-19T03:57:29.514Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://desirability2.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":"2021-08-14T20:22:48.000Z","updated_at":"2024-10-23T15:06:24.000Z","dependencies_parsed_at":"2022-07-19T22:03:10.410Z","dependency_job_id":"1c83eeb6-87d6-4533-8fee-8b25795e11cf","html_url":"https://github.com/tidymodels/desirability2","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fdesirability2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fdesirability2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fdesirability2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fdesirability2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidymodels","download_url":"https://codeload.github.com/tidymodels/desirability2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249885752,"owners_count":21340189,"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:05.553Z","updated_at":"2025-04-21T14:32:10.174Z","avatar_url":"https://github.com/tidymodels.png","language":"R","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# desirability2\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n[![Codecov test coverage](https://codecov.io/gh/tidymodels/desirability2/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/desirability2?branch=main)\n[![R-CMD-check](https://github.com/tidymodels/desirability2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/desirability2/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nDesirability functions are simple but useful tools for simultaneously optimizing several things at once. For each input, a translation function is used to map the input values between zero and one where zero is unacceptable and one is most desirable. \n\nFor example, [Kuhn and Johnson (2019)](https://bookdown.org/max/FES/genetic-algorithms.html#coercing-sparsity) use these functions during feature selection to help a genetic algorithm choose which predictors to include in a model that simultaneously improves performance and reduces the number of predictors. \n\nThe desirability2 package improves on the original [desirability package](https://cran.r-project.org/package=desirability) by enabling in-line computations that can be used with dplyr pipelines. \n\n## A ranking example\n\nSuppose a classification model with two tuning parameters (`penalty` and `mixture`) and several performance measures (multinomial log-loss, area under the precision-recall curve, and the area under the ROC curve). For each tuning parameter, the average number of features used in the model was also computed: \n\n```{r, start, include = FALSE}\nlibrary(desirability2)\nlibrary(dplyr)\n```\n\n```{r}\nlibrary(desirability2)\nlibrary(dplyr)\nclassification_results\n```\n\nWe might want to pick a model in a way that maximizes the area under the ROC curve with a minimum number of model terms. We know that the ROC measures is usually between 0.5 and 1.0. We can define a desirability function to _maximize_ this value using:\n\n```r\nd_max(roc_auc, low = 1/2, high = 1)\n```\n\nFor the number of terms, if we wanted to minimize this under the condition that there should be less than 100 features, a minimal desirability function can be appropriate: \n\n```r\nd_min(num_features, low = 1, high = 100)\n```\n\nWe can add these as columns to the data using a `mutate()` statement along with a call to the function that blends these values using a geometric mean: \n\n```{r}\nclassification_results %\u003e% \n  select(-mn_log_loss, -pr_auc) %\u003e% \n  mutate(\n    d_roc   = d_max(roc_auc, low = 1/2, high = 1), \n    d_terms = d_min(num_features, low = 1, high = 50),\n    d_both    = d_overall(d_roc, d_terms)\n  ) %\u003e% \n  # rank from most desirable to least:\n  arrange(desc(d_both))\n```\n\nSee `?inline_desirability` for details on the individual desirability functions. \n\n\n## Code of Conduct\n  \nPlease note that the desirability2 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## 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- If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/desirability2/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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fdesirability2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidymodels%2Fdesirability2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fdesirability2/lists"}