Metadata-Version: 2.4
Name: ReMoDe
Version: 0.3.0
Summary: Recursive Mode Detection for ordinal data
Author-email: Javier Garcia-Bernardo <j.garciabernardo@uu.nl>, Madlen Hoffstadt <m.f.hoffstadt@uva.nl>, Han van der Maas <h.l.j.vanderMaas@uva.nl>
License: MIT License
        
        Copyright (c) 2024 SoDa
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: homepage, https://github.com/sodascience/remode
Project-URL: repository, https://github.com/sodascience/remode
Keywords: mode detection,remode,ordinal data,modality,maximum detection
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: pandas
Requires-Dist: scipy
Provides-Extra: test
Requires-Dist: ruff; extra == "test"
Requires-Dist: pytest; extra == "test"
Requires-Dist: mypy; extra == "test"
Provides-Extra: docs
Requires-Dist: sphinx<9,>=7; extra == "docs"
Requires-Dist: pydata-sphinx-theme>=0.15; extra == "docs"
Requires-Dist: myst-parser<5,>=2; extra == "docs"
Requires-Dist: myst-nb<2,>=1; extra == "docs"
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
Requires-Dist: sphinx-design>=0.6; extra == "docs"
Dynamic: license-file

# ReMoDe: a Python library for efficient mode detection in ordinal data distributions.

[![Docs](https://readthedocs.org/projects/remode/badge/?version=latest)](https://remode.readthedocs.io/en/latest/)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18743126.svg)](https://doi.org/10.5281/zenodo.18743126)
[![CI](https://github.com/sodascience/remode/actions/workflows/ci.yml/badge.svg)](https://github.com/sodascience/remode/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/remode.svg)](https://pypi.org/project/remode/)
[![Python versions](https://img.shields.io/pypi/pyversions/remode.svg)](https://pypi.org/project/remode/)

`ReMoDe` (Recursive Mode Detection) is a Python library designed for robust mode detection in ordinal data distributions. By default it uses a bootstrap significance test (with binomial and Fisher alternatives) to determine whether a candidate maximum is a true local mode.

**Are you an `R` user?** Please find the `R` version here: https://cran.r-project.org/web/packages/remode/index.html


### Features
- Mode Detection: Identifies all potential local maxima in the dataset.
- Statistical Tests: Implements bootstrap (default), Fisher's exact, and binomial tests to validate modes.
- Mode Statistics: Returns per-mode p-values and approximate Bayes factors.
- Modality Definition: Supports `shape_based` (default) and `peak_based` definitions.
- Data Formatting: Converts raw data into histogram format for analysis.
- Stability Analysis: Includes functionality to assess the stability of detected modes using jackknife resampling.
- Visualization: Provides methods to plot the histogram of data along with identified modes.

### Installation

```bash
pip install remode
```

### Usage

Here is a simple example of how to use the ReMode library:

```python
from remode import ReMoDe

# Sample data (histogram counts)
xt_count = [8, 20, 5, 2, 6, 2, 30]

# Create an instance of ReMoDe
detector = ReMoDe()  # defaults: bootstrap test, descriptive_peaks correction, shape_based definition

# Fit model
results = detector.fit(xt_count)
# results contains:
# - nr_of_modes
# - modes
# - p_values
# - approx_bayes_factors

# Plot the results
detector.plot_maxima()

# Perform stability analysis
stability_info = detector.remode_stability(percentage_steps=50)

```


See also the tutorial [here](https://github.com/sodascience/remode/blob/main/tutorial.ipynb).


### Citation

Please cite the following paper:
```
Hoffstadt, M., Waldorp, L., Garcia‐Bernardo, J., & van der Maas, H. (2026). ReMoDe–Recursive modality detection in distributions of ordinal data. British Journal of Mathematical and Statistical Psychology.
```
and the following software
```
Garcia-Bernardo, J., Hoffstadt, M., Waldorp, L., & van der Maas, H. L. J. (2026). ReMoDe: a Python library for efficient mode detection in ordinal data distributions. Zenodo. https://doi.org/10.5281/zenodo.18743126
```

### Contributing

Contributions are what make the open source community an amazing place
to learn, inspire, and create. Any contributions you make are **greatly
appreciated**.

Please refer to the
[CONTRIBUTING](https://github.com/sodascience/remode/blob/main/CONTRIBUTING.md)
file for more information on issues and pull requests.


### License

This project is licensed under the GNU GPLv3. This allows you to do almost anything they want with this project, except distributing closed source versions. 


## Contact

This project is a port of the R version of [`ReMoDe`](https://github.com/hvdmaas/remode). It is maintained by the [ODISSEI Social Data
Science (SoDa)](https://odissei-data.nl/nl/soda/) team.

<img src="soda_logo.png" alt="SoDa logo" width="250px"/>

Do you have questions, suggestions, or remarks? File an issue in the issue
tracker!
