{"id":19253605,"url":"https://github.com/tidymodels/discrim","last_synced_at":"2025-04-09T20:06:44.378Z","repository":{"id":38049823,"uuid":"213528222","full_name":"tidymodels/discrim","owner":"tidymodels","description":"Wrappers for discriminant analysis and naive Bayes models for use with the parsnip package","archived":false,"fork":false,"pushed_at":"2024-10-23T15:28:11.000Z","size":10540,"stargazers_count":29,"open_issues_count":4,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-09T20:06:40.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://discrim.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":"2019-10-08T02:11:36.000Z","updated_at":"2025-01-27T14:29:31.000Z","dependencies_parsed_at":"2024-04-10T01:40:36.551Z","dependency_job_id":"b900c0f1-fe5f-4950-a266-01bb4be93bd7","html_url":"https://github.com/tidymodels/discrim","commit_stats":{"total_commits":157,"total_committers":6,"mean_commits":"26.166666666666668","dds":0.4267515923566879,"last_synced_commit":"434d7317167a865bca336936cd4a5d7d21bdaad3"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fdiscrim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fdiscrim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fdiscrim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fdiscrim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidymodels","download_url":"https://codeload.github.com/tidymodels/discrim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"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.451Z","updated_at":"2025-04-09T20:06:44.357Z","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)\nlibrary(ggplot2)\n```\n\n# discrim\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/discrim)](https://cran.r-project.org/package=discrim)\n[![Codecov test coverage](https://codecov.io/gh/tidymodels/discrim/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/discrim?branch=main)\n[![R-CMD-check](https://github.com/tidymodels/discrim/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/discrim/actions/workflows/R-CMD-check.yaml)\n[![Lifecycle: experimental](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/discrim/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/discrim)\n\u003c!-- badges: end --\u003e\n\n`discrim` contains simple bindings to enable the `parsnip` package to fit various discriminant analysis models, such as \n\n-   Linear discriminant analysis (LDA, simple and regularized)\n-   Quadratic discriminant analysis (QDA, simple and regularized)\n * Regularized discriminant analysis (RDA, via [Friedman (1989)](https://scholar.google.com/scholar?hl=en\u0026as_sdt=0%2C7\u0026q=%22Regularized+Discriminant+Analysis%22\u0026btnG=))\n * Flexible discriminant analysis (FDA) using MARS features\n * Naive Bayes models\n \n## Installation\n\nYou can install the released version of discrim from [CRAN](https://CRAN.R-project.org) with:\n\n``` r\ninstall.packages(\"discrim\")\n```\n\nAnd the development version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"pak\")\npak::pak(\"tidymodels/discrim\")\n```\n  \n## Available Engines\n\nThe discrim package provides engines for the models in the following table.\n\n```{r, echo=FALSE, message=FALSE}\nlibrary(parsnip)\n\nparsnip_models \u003c- get_from_env(\"models\") %\u003e%\n  setNames(., .) %\u003e%\n  purrr::map_dfr(get_from_env, .id = \"model\")\n\nlibrary(discrim)\n\ndiscrim_models \u003c- get_from_env(\"models\") %\u003e%\n  setNames(., .) %\u003e%\n  purrr::map_dfr(get_from_env, .id = \"model\")\n\ndplyr::anti_join(\n  discrim_models, parsnip_models, \n  by = c(\"model\", \"engine\", \"mode\")\n) %\u003e%\n  knitr::kable()\n```\n\n## Example\n\nHere is a simple model using a simulated two-class data set contained in the package:\n\n```{r example}\n#| fig-alt: \"Scatter chart. X1 along the x-axis, X2 along the y-axis. points are scattered, with a trend between X1 and X2. Most of the middle points are colored and labeled Class2, with the remaining points labeled Class1. Two connected straight lines, doing its best to separate the two classes.\"\nlibrary(discrim)\n\nparabolic_grid \u003c-\n  expand.grid(X1 = seq(-5, 5, length = 100),\n              X2 = seq(-5, 5, length = 100))\n\nfda_mod \u003c-\n  discrim_flexible(num_terms = 3) %\u003e%\n  # increase `num_terms` to find smoother boundaries\n  set_engine(\"earth\") %\u003e%\n  fit(class ~ ., data = parabolic)\n\nparabolic_grid$fda \u003c-\n  predict(fda_mod, parabolic_grid, type = \"prob\")$.pred_Class1\n\nlibrary(ggplot2)\nggplot(parabolic, aes(x = X1, y = X2)) +\n  geom_point(aes(col = class), alpha = .5) +\n  geom_contour(data = parabolic_grid, aes(z = fda), col = \"black\", breaks = .5) +\n  theme_bw() +\n  theme(legend.position = \"top\") +\n  coord_equal()\n```\n\n## Contributing\n\nThis project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/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://community.rstudio.com/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/discrim/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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fdiscrim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidymodels%2Fdiscrim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fdiscrim/lists"}