https://github.com/jiayaobo/stamox

make your statistical research faster

https://github.com/jiayaobo/stamox

Science Score: 13.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
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.5%) to scientific vocabulary

Keywords

functional-programming gpu jax python statistics
Last synced: 6 months ago · JSON representation

Repository

make your statistical research faster

Basic Info
Statistics
  • Stars: 12
  • Watchers: 1
  • Forks: 0
  • Open Issues: 3
  • Releases: 3
Topics
functional-programming gpu jax python statistics
Created over 3 years ago · Last pushed over 2 years ago
Metadata Files
Readme

README.md

Stamox

PyPI version PyPI - License PyPI - Downloads GitHub stars

Hello Stamox, Why Another Wheel?

Why Another Wheel?

What stamox does is really simple, just make it possible, it aims to provide a statistic interface for JAX. But nowadays, we have so many statistic packages around the world varying from languages, for python, statsmodels just works great, for R, tidyverse derived packages are so delicate and easy to use. So why build another wheel?

Three reasons I think:

  • Personal interest, as a student of statistics, I want to learn more about statistics and machine learning, proficient knowledge comes from books but more from practice, write down the code behind the theory is a good way to learn.

  • Speed, JAX is really fast, and Equinox is a good tool to make JAX more convenient, backend of JAX is XLA, which makes it possible to compile the code to GPU or TPU, and it is really fast.

  • Easy of Use, %>% is delicate operation in R, it combines the functions to a pipe and make the code more readable, and stamox is inspired by it, and I want to take a try to make it convenient in python with >>.

And here're few benchmarks:

generate random variables

benchmark

calculate cdf

benchmark

Installation

```bash pip install -U stamox

or

pip install git+https://github.com/JiaYaobo/stamox.git ```

Documentation

More comprehensive introduction and examples can be found in the documentation.

Quick Start

Similar but faster distribution functions to R

You can simply import all functions from stamox.functions

```python from stamox.functions import dnorm, pnorm, qnorm, rnorm import jax.random as jrandom

key = jrandom.PRNGKey(20010813)

random

x = rnorm(key, sample_shape=(1000, ))

cdf

prob = pnorm(x)

ppf

qntl = qnorm(prob)

pdf

dense = dnorm(x) ```

Fearless Pipeable

>> is the pipe operator, which is the similar to |> in F# and Elixir or %>% in R.

  • You can simply import all pipeable functions from pipe_functions

```python import jax.random as jrandom import stamox.pipefunctions as PF from stamox import pipejit

key = jrandom.PRNGKey(20010813)

@pipejit def f(x): return [3 * x[:, 0] + 2 * x[:, 1] - x[:, 2], x] # [y, X] pipe = PF.rnorm(sampleshape=(1000, 3)) >> f >> PF.lm state = pipe(key) print(state.params) ```

  • Custom Functions Pipeable

```python from stamox import makepipe, makepartial_pipe, Pipeable import jax.numpy as jnp import jax.random as jrandom

x = jnp.ones((1000, ))

single input, simply add make pipe

@make_pipe def f(x): return x ** 2

multiple input, decorate with make partial pipe

@makepartialpipe def g(x, y): return x + y

x -> f -> g(y=2.) -> f -> g(y=3.) -> f

h = Pipeable(x) >> f >> g(y=2.) >> f >> g(y=3.) >> f

h is a Pipeable object, you can call it to get the result

print(h()) ```

  • Compatible With JAX and Equinox

You can use autograd features from JAX and Equinox with Stamox easily.

```python import jax.numpy as jnp from stamox import makepartialpipe from equinox import filterjit, filtervmap, filter_grad

@makepartialpipe @filterjit @filtervmap @filter_grad def f(x, y): return y * x ** 3

df/dx = 3y * x^2

g = f(y=3.) # derive with respect to x given y=3 g(jnp.array([1., 2., 3.])) ```

Or vmap, pmap, jit features integrated with Stamox:

```python from stamox import pipevmap, pipejit

@pipevmap @pipejit def f(x): return x ** 2

g = f >> f >> f print(g(jnp.array([1, 2, 3]))) ```

Linear Regression with Formula

```python import pandas as pd import numpy as np from stamox.functions import lm # or from stamox.pipe_functions import lm

x = np.random.uniform(size=(1000, 3)) y = 2 * x[:,0] + 3 * x[:,1] + 4 * x[:,2] + np.random.normal(size=1000) df = pd.DataFrame(x, columns=['x1', 'x2', 'x3']) df['y'] = y

lm(df, 'y~x1+x2+x3').params ```

Acceleration Support

JAX can be accelerated by GPU and TPU. So, Stamox is compatible with them.

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

  1. Fork the stamox repository by clicking the Fork button on the repository page. This creates a copy of the stamox repository in your own account.
  2. Install Python >= 3.8 locally in order to run tests.
  3. pip installing your fork from source. This allows you to modify the code and immediately test it out: bash git clone https://github.com/JiaYaobo/stamox.git cd stamox
  4. Add the stamox repo as an upstream remote, so you can use it to sync your changes. bash git remote add upstream https://github.com/JiaYaobo/stamox.git
  5. Create a branch for local development: bash git checkout -b name-of-your-bugfix-or-feature
  6. Install requirements for tests bash pip install -r tests/requirements.txt
  7. Make sure the tests pass by running the following command from the top of the repository: bash pytest tests/
  8. Commit your changes and push your branch to GitHub: bash git add . git commit -m "Your detailed description of your changes." Then sync your code with the main repo: bash git fetch upstream git rebase upstream/main Finally, push your changes to your fork: bash git push --set-upstream origin name-of-your-bugfix-or-feature
  9. Submit a pull request through the GitHub website.

See More

JAX

Equinox

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 4
  • Total pull requests: 8
  • Average time to close issues: 1 minute
  • Average time to close pull requests: about 1 hour
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • JiaYaobo (3)
  • JeppeKlitgaard (1)
Pull Request Authors
  • JiaYaobo (8)
Top Labels
Issue Labels
enhancement (1) good first issue (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 21 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 12
  • Total maintainers: 1
pypi.org: stamox

Accelerate Your Statistical Analysis with JAX.

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 21 Last month
Rankings
Dependent packages count: 6.6%
Average: 21.0%
Downloads: 25.8%
Dependent repos count: 30.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/python-package.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
docs/requirements.txt pypi
  • jax *
  • jinja2 ==3.0.3
  • mkdocs ==1.3.0
  • mkdocs-material ==7.3.6
  • mkdocs_include_exclude_files ==0.0.1
  • mkdocstrings ==0.17.0
  • mknotebooks ==0.7.1
  • pygments ==2.14.0
  • pymdown-extensions ==9.4
  • pytkdocs_tweaks ==0.0.5
pyproject.toml pypi
setup.py pypi
tests/requirements.txt pypi
  • equinox * test
  • numpy * test
  • pandas * test
  • psutil * test
  • scikit-learn * test
  • statsmodels * test