ChainoPy

ChainoPy: A Python Library for Discrete Time Markov Chain Based Stochastic Analysis - Published in JOSS (2024)

https://github.com/aadya940/chainopy

Science Score: 98.0%

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

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

bayesian-data-analysis bayesian-inference bayesian-statistics data-analysis data-science deep-learning forecasting machine-learning markov-chain markov-model markov-process time-series time-series-analysis

Scientific Fields

Earth and Environmental Sciences Physical Sciences - 69% confidence
Sociology Social Sciences - 64% confidence
Last synced: 4 months ago · JSON representation ·

Repository

ChainoPy: A Python Library for Discrete Time Markov Chain based stochastic analysis

Basic Info
Statistics
  • Stars: 21
  • Watchers: 1
  • Forks: 1
  • Open Issues: 7
  • Releases: 5
Topics
bayesian-data-analysis bayesian-inference bayesian-statistics data-analysis data-science deep-learning forecasting machine-learning markov-chain markov-model markov-process time-series time-series-analysis
Created almost 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

logo1

ChainoPy 1.0

A Python 🐍 Package for Markov Chains, Markov Chain Neural Networks and Markov Switching Models.

Why ChainoPy?

  • Covers most of the fundamental agorithms for Markov Chain Analysis
  • Memory efficient Model saving
  • Faster than other libraries (eg: 5x Faster than PyDTMC)
  • First Package to contain functions to build equivalent Markov Chain Neural Networks from Markov Chains.
  • Contains Markov Switching Models for Univariate Time Series Analysis
  • Supports Numpy 2.0.0

How to Install ChainoPy?

Using pip

bash pip install chainopy

Build from Source

Before you begin, ensure you have the following installed on your system: - Python (> 3.9 )

1. Clone the Repository

Fork and Clone the Chainopy repository to your local machine using Git:

bash git clone https://github.com/aadya940/chainopy.git

Navigate to the directory which contains the pyproject.toml file.

2. Install the package

bash python -m build

How to run ChainoPy Tests?

  1. Clone the project locally
  2. Install packages mentioned in requirements.txt and requirements_test.txt
  3. Navigate to the directory containing tests folder
  4. Run the following command: bash python -m pytest tests/

You're all Set! 😃 👍

The Basics

Create Markov Chains and Markov Chain Neural Networks as follows: ```

import chainopy mc = chainopy.MarkovChain([[0, 1], [1, 0]], states = ["Rain", "No-Rain"]) # Creates a two-states Markov Chain stored in mc. neuralnetwork = chainopy.MarkovChainNeuralNetwork(mc, numlayers = 5) # Creates a 5-layered Neural Network that simulates mc. ```

image

Create a Markov Switching Model as follows:

```

import numpy as np import random from chainopy import MarkovSwitchingModel X = np.random.normal(0, 1, 1000) + np.random.logistic(5, 10, 1000) # Generate Random Training Data regimecol = [random.choice(["High", "Low", "Stagnant"]) for _ in range(1000)] # Generate Regimes for Training Data mod = MarkovSwitchingModel() mod.fit(X, regimecol) y, regime_y = mod.predict("High", steps=20) ```

Generates Data as follows: - X: We generate 1000 data points by combining a normal distribution (mean = 0, standard deviation = 1) with a logistic distribution (mean = 5, scale = 10). This creates a complex dataset with variations. - regime_col: We assign one of three possible regimes ("High", "Low", "Stagnant") to each data point. This is done by randomly selecting one of these regimes for each of the 1000 data points.

Later, Creates a Markov Switching Model using chainopy.MarkovSwitchingModel with 3 regimes (High, Low and Stagnant) and predicts the next twenty steps if the start states is "High".

Example - Apple Weekly High Stock data prediction using chainopy.MarkovSwitchingModel

image

How to Contribute?

  1. Fork the Project.
  2. Clone the Project locally.
  3. Create a New Branch to Contribute.
  4. run pip install -r requirements.txt and pip install -r requirements_test.txt to download dependencies.
  5. Do the changes of interest (Make sure to write docstrings).
  6. Write Unit Tests and test your implementation.
  7. Format the code using the Black Formatter.
  8. Push the changes and submit a Pull Request.

Note: If your implementation is Cython, justify its usage in your PR to make the code more maintainable.

Cite ChinoPy

DOI

@article{Chinubhai2024ChainoPy, author = {Aadya A. Chinubhai}, title = {ChainoPy: A Python Library for Discrete Time Markov Chain Based Stochastic Analysis}, journal = {Journal of Open Source Software}, volume = {9}, number = {100}, pages = {6880}, year = {2024}, doi = {10.21105/joss.06880}, url = {https://joss.theoj.org/papers/10.21105/joss.06880} }

Owner

  • Name: Aadya Chinubhai
  • Login: aadya940
  • Kind: user

UG. Student at Ahmedabad University.

JOSS Publication

ChainoPy: A Python Library for Discrete Time Markov Chain Based Stochastic Analysis
Published
August 16, 2024
Volume 9, Issue 100, Page 6880
Authors
Aadya A. Chinubhai
School of Engineering and Applied Sciences (SEAS), Ahmedabad University, Ahmedabad, Gujarat, India
Editor
Beatriz Costa Gomes ORCID
Tags
Markov Chains Markov Chain Neural Networks Stochastic Analysis High Performance Computing

Citation (citation.cff)

cff-version: "1.2.0"
authors:
- family-names: Chinubhai
  given-names: Aadya A.
doi: 10.5281/zenodo.13305155
message: If you use this software, please cite our article in the
  Journal of Open Source Software.
preferred-citation:
  authors:
  - family-names: Chinubhai
    given-names: Aadya A.
  date-published: 2024-08-16
  doi: 10.21105/joss.06880
  issn: 2475-9066
  issue: 100
  journal: Journal of Open Source Software
  publisher:
    name: Open Journals
  start: 6880
  title: "ChainoPy: A Python Library for Discrete Time Markov Chain
    Based Stochastic Analysis"
  type: article
  url: "https://joss.theoj.org/papers/10.21105/joss.06880"
  volume: 9
title: "ChainoPy: A Python Library for Discrete Time Markov Chain Based
  Stochastic Analysis"

GitHub Events

Total
  • Issues event: 1
  • Watch event: 6
  • Issue comment event: 1
Last Year
  • Issues event: 1
  • Watch event: 6
  • Issue comment event: 1

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 389
  • Total Committers: 2
  • Avg Commits per committer: 194.5
  • Development Distribution Score (DDS): 0.003
Past Year
  • Commits: 19
  • Committers: 1
  • Avg Commits per committer: 19.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
aadya940 a****a@u****i 388
Michalis Panayides m****n@t****i 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 20
  • Total pull requests: 6
  • Average time to close issues: 18 days
  • Average time to close pull requests: 40 minutes
  • Total issue authors: 5
  • Total pull request authors: 2
  • Average comments per issue: 2.3
  • Average comments per pull request: 0.0
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 7
  • Pull requests: 0
  • Average time to close issues: about 1 month
  • Average time to close pull requests: N/A
  • Issue authors: 4
  • Pull request authors: 0
  • Average comments per issue: 1.14
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • aadya940 (16)
  • braniii (3)
  • s-agapov (1)
  • MichalisPanayides (1)
  • ashishbijlani (1)
Pull Request Authors
  • aadya940 (9)
  • MichalisPanayides (2)
Top Labels
Issue Labels
good first issue (2) discussion (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 130 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 5
  • Total maintainers: 1
pypi.org: chainopy

A Python Library for Markov Chain based Stochastic Analysis!

  • Homepage: https://github.com/aadya940/chainopy
  • Documentation: https://chainopy.readthedocs.io/
  • License: Copyright 2024 Aadya Chinubhai Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  • Latest release: 1.0.3
    published over 1 year ago
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 130 Last month
Rankings
Dependent packages count: 10.6%
Stargazers count: 18.3%
Average: 30.4%
Forks count: 32.5%
Dependent repos count: 59.9%
Maintainers (1)
Last synced: 4 months ago

Dependencies

requirements.txt pypi
  • Cython *
  • cython *
  • matplotlib *
  • networkx *
  • numba *
  • numpy *
  • scipy *
  • torch *
  • xarray *
requirements_doc.txt pypi
  • furo *
  • myst-parser *
  • sphinx *
requirements_test.txt pypi
  • numpy * test
  • pydtmc * test
  • pytest * test
setup.py pypi
.github/workflows/ci.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/draft-pdf.yml actions
  • actions/checkout v4 composite
  • actions/upload-artifact v1 composite
  • openjournals/openjournals-draft-action master composite