https://github.com/corybrunson/ordered

Parsnip bindings for ordinal prediction models

https://github.com/corybrunson/ordered

Science Score: 39.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
    Found 8 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.2%) to scientific vocabulary

Keywords

ordinal-classification ordinal-regression parsnip tidymodels
Last synced: 6 months ago · JSON representation

Repository

Parsnip bindings for ordinal prediction models

Basic Info
  • Host: GitHub
  • Owner: corybrunson
  • License: other
  • Language: R
  • Default Branch: main
  • Homepage:
  • Size: 103 KB
Statistics
  • Stars: 7
  • Watchers: 2
  • Forks: 0
  • Open Issues: 8
  • Releases: 0
Topics
ordinal-classification ordinal-regression parsnip tidymodels
Created over 1 year ago · Last pushed 6 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%"
)
```

# ordered


[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/ordered)](https://CRAN.R-project.org/package=ordered)
[![R-CMD-check](https://github.com/corybrunson/ordered/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/corybrunson/ordered/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/corybrunson/ordered/branch/main/graph/badge.svg)](https://app.codecov.io/gh/corybrunson/ordered?branch=main)


`ordered` is a [parsnip](https://parsnip.tidymodels.org/) extension to enable additional classification models for ordinal outcomes (e.g., "low", "medium", "high"). While there are several model/engine combinations in the parsnip package that can be used, this package adds:

 - ordinal regression via `MASS::polr()`
 - ordinal classification trees via `rpartScore::rpartScore()` ([Galimberti, Soffritti, and Di Maso, 2012](https://doi.org/10.18637/jss.v047.i10))
 - ordinal forests via `ordinalForest::ordfor()` ([Hornung, 2020](https://doi.org/10.1007/s00357-018-9302-x))

More will be added. Under consideration are:

 - ordinal regression via `VGAM::vglm()` ([Yee, 2015](https://doi.org/10.1007%2F978-1-4939-2818-7))
 - ordinal regression via `ordinalNet::ordinalNet()` ([Wurm, Hanlon, and Rathouz, 2021](https://doi.org/10.18637/jss.v099.i06))
 - Bayesian ordinal regression via `ordinalbayes::ordinalbayes()` ([Zhang and Archer, 2021](https://doi.org/10.1186%2Fs12859-021-04432-w))
 - ordinal regression via `ordinal::clm()` ([Christensen, 2023](https://cran.uni-muenster.de/web/packages/ordinal/vignettes/clm_article.pdf))

There are some existing features in tidymodels packages that are useful for ordinal outcomes: 

 - The [partykit](https://cran.r-project.org/package=partykit) engines for `parsnip::decision_tree()` and `parsnip::rand_forest()` use the ordered nature of the factors to train the model. 
 - The yardstick package has `yardstick::kap()` for weighted and unweighted Kappa statistics (the former being of more interest). Also, `yardstick::classification_cost()` can utilize more complex cost structures and uses the class probabilities for estimation. 

## Installation

You can install the development version of ordered like so:

``` r
# install.packages("pak")
pak::pak("corybrunson/ordered", dependencies = FALSE)
```

Currently, ordered relies on engine and dial registration in the following forks:

``` r
pak::pak("corybrunson/parsnip@ordered", dependencies = FALSE)
pak::pak("corybrunson/dials@ordered", dependencies = FALSE)
```

## Example

Here is a simple example using computational chemistry data to predict the permeability of a molecule: 

```{r}
library(ordered)
library(dplyr)

data(caco, package = "QSARdata")

caco_dat <-
  inner_join(caco_Outcome, caco_Dragon, by = "Molecule") %>%
  as_tibble() %>%
  select(class = Class, mol_weight = QikProp_mol_MW,
         volume = QikProp_volume, ClogP)
  caco_train <- caco_dat[-(1:5), ]
  caco_test  <- caco_dat[ (1:5), ]

ord_rf_spec <- 
  rand_forest(mtry = 2, trees = 100) %>% # you should really use many more trees
  set_mode("classification") %>%
  set_engine("ordinalForest")

set.seed(382)
ord_rf_fit <- ord_rf_spec %>% fit(class ~ ., data = caco_train)
augment(ord_rf_fit, caco_test)
```

## Code of Conduct

Please note that the ordered 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.

Owner

  • Name: Cory Brunson
  • Login: corybrunson
  • Kind: user
  • Location: Gainesville, FL
  • Company: @LaboratoryForSystemsMedicine

Mathematician by training, data scientist by testing. Relatively new to pretty much everything.

GitHub Events

Total
  • Issues event: 2
  • Watch event: 1
  • Delete event: 3
  • Issue comment event: 3
  • Push event: 31
  • Pull request review comment event: 2
  • Pull request review event: 2
  • Pull request event: 3
  • Create event: 3
Last Year
  • Issues event: 2
  • Watch event: 1
  • Delete event: 3
  • Issue comment event: 3
  • Push event: 31
  • Pull request review comment event: 2
  • Pull request review event: 2
  • Pull request event: 3
  • Create event: 3

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 2
  • Total pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: about 7 hours
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: about 7 hours
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • corybrunson (2)
Pull Request Authors
  • corybrunson (2)
Top Labels
Issue Labels
Pull Request Labels