discrim

Wrappers for discriminant analysis and naive Bayes models for use with the parsnip package

https://github.com/tidymodels/discrim

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: scholar.google
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.8%) to scientific vocabulary

Keywords from Contributors

tidy-data tidyverse
Last synced: 10 months ago · JSON representation

Repository

Wrappers for discriminant analysis and naive Bayes models for use with the parsnip package

Basic Info
Statistics
  • Stars: 31
  • Watchers: 6
  • Forks: 3
  • Open Issues: 3
  • Releases: 8
Created over 6 years ago · Last pushed 11 months ago
Metadata Files
Readme Changelog License Code of conduct

README.Rmd

---
output: github_document
---



```{r}
#| include: false
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
library(ggplot2)
```

# discrim discrim website


[![CRAN status](https://www.r-pkg.org/badges/version/discrim)](https://cran.r-project.org/package=discrim)
[![Codecov test coverage](https://codecov.io/gh/tidymodels/discrim/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/discrim?branch=main)
[![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)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![Codecov test coverage](https://codecov.io/gh/tidymodels/discrim/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/discrim)


`discrim` contains simple bindings to enable the `parsnip` package to fit various discriminant analysis models, such as 

-   Linear discriminant analysis (LDA, simple and regularized)
-   Quadratic discriminant analysis (QDA, simple and regularized)
 * Regularized discriminant analysis (RDA, via [Friedman (1989)](https://scholar.google.com/scholar?hl=en&as_sdt=0%2C7&q=%22Regularized+Discriminant+Analysis%22&btnG=))
 * Flexible discriminant analysis (FDA) using MARS features
 * Naive Bayes models
 
## Installation

You can install the released version of discrim from [CRAN](https://CRAN.R-project.org) with:

``` r
install.packages("discrim")
```

And the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("pak")
pak::pak("tidymodels/discrim")
```
  
## Available Engines

The discrim package provides engines for the models in the following table.

```{r}
#| echo: false
#| message: false
library(parsnip)

parsnip_models <- setNames(nm = get_from_env("models")) |>
  purrr::map_dfr(get_from_env, .id = "model")

library(discrim)

discrim_models <- setNames(nm = get_from_env("models")) |>
  purrr::map_dfr(get_from_env, .id = "model")

dplyr::anti_join(
  discrim_models, parsnip_models, 
  by = c("model", "engine", "mode")
) |>
  knitr::kable()
```

## Example

Here is a simple model using a simulated two-class data set contained in the package:

```{r}
#| label: example
#| 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."
library(discrim)

parabolic_grid <-
  expand.grid(X1 = seq(-5, 5, length = 100),
              X2 = seq(-5, 5, length = 100))

fda_mod <-
  discrim_flexible(num_terms = 3) |>
  # increase `num_terms` to find smoother boundaries
  set_engine("earth") |>
  fit(class ~ ., data = parabolic)

parabolic_grid$fda <-
  predict(fda_mod, parabolic_grid, type = "prob")$.pred_Class1

library(ggplot2)
ggplot(parabolic, aes(x = X1, y = X2)) +
  geom_point(aes(col = class), alpha = .5) +
  geom_contour(data = parabolic_grid, aes(z = fda), col = "black", breaks = .5) +
  theme_bw() +
  theme(legend.position = "top") +
  coord_equal()
```

## Contributing

This 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.

- 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&tags=tidymodels,question).

- If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/discrim/issues).

- 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.

- 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/).

Owner

  • Name: tidymodels
  • Login: tidymodels
  • Kind: organization

GitHub Events

Total
  • Issues event: 6
  • Watch event: 1
  • Delete event: 3
  • Push event: 16
  • Pull request event: 8
  • Create event: 4
Last Year
  • Issues event: 6
  • Watch event: 1
  • Delete event: 3
  • Push event: 16
  • Pull request event: 8
  • Create event: 4

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 175
  • Total Committers: 6
  • Avg Commits per committer: 29.167
  • Development Distribution Score (DDS): 0.474
Past Year
  • Commits: 13
  • Committers: 4
  • Avg Commits per committer: 3.25
  • Development Distribution Score (DDS): 0.308
Top Committers
Name Email Commits
Max Kuhn m****n@g****m 92
Emil Hvitfeldt e****t@g****m 51
Julia Silge j****e@g****m 25
Hannah Frick h****h@r****m 5
Simon P. Couch s****h@g****m 1
Gábor Csárdi c****r@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 28
  • Total pull requests: 47
  • Average time to close issues: 3 months
  • Average time to close pull requests: 7 days
  • Total issue authors: 11
  • Total pull request authors: 7
  • Average comments per issue: 1.64
  • Average comments per pull request: 1.09
  • Merged pull requests: 44
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 6
  • Average time to close issues: 3 days
  • Average time to close pull requests: 1 day
  • Issue authors: 2
  • Pull request authors: 4
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • EmilHvitfeldt (11)
  • topepo (7)
  • juliasilge (2)
  • deschen1 (2)
  • bbuchsbaum (1)
  • jennybc (1)
  • ttrodrigz (1)
  • lymanmark (1)
  • tomwagstaff-opml (1)
  • royfrancis (1)
  • hfrick (1)
Pull Request Authors
  • EmilHvitfeldt (23)
  • topepo (20)
  • juliasilge (4)
  • hfrick (4)
  • gaborcsardi (2)
  • simonpcouch (2)
  • jmarshallnz (1)
Top Labels
Issue Labels
upkeep (4) feature (4) tidy-dev-day :nerd_face: (3) documentation (2) bug (2)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 2,467 last-month
  • Total docker downloads: 14
  • Total dependent packages: 2
  • Total dependent repositories: 21
  • Total versions: 10
  • Total maintainers: 1
cran.r-project.org: discrim

Model Wrappers for Discriminant Analysis

  • Versions: 10
  • Dependent Packages: 2
  • Dependent Repositories: 21
  • Downloads: 2,467 Last month
  • Docker Downloads: 14
Rankings
Dependent repos count: 6.0%
Downloads: 8.1%
Stargazers count: 9.9%
Average: 13.6%
Forks count: 17.0%
Dependent packages count: 18.1%
Docker downloads count: 22.5%
Maintainers (1)
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.4 depends
  • parsnip >= 0.2.0 depends
  • dials * imports
  • purrr * imports
  • rlang * imports
  • tibble * imports
  • withr * imports
  • MASS * suggests
  • covr * suggests
  • dplyr * suggests
  • earth * suggests
  • ggplot2 * suggests
  • klaR * suggests
  • knitr * suggests
  • mda * suggests
  • mlbench * suggests
  • modeldata * suggests
  • naivebayes * suggests
  • rmarkdown * suggests
  • sda * suggests
  • sparsediscrim >= 0.3.0 suggests
  • spelling * suggests
  • testthat >= 3.0.0 suggests
  • xml2 * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/lock.yaml actions
  • dessant/lock-threads v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/pr-fetch v2 composite
  • r-lib/actions/pr-push v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite