Skip to content

Commit

Permalink
Showcase polars support (#90)
Browse files Browse the repository at this point in the history
* add polars example

* specify in the list of features
  • Loading branch information
wd60622 authored Sep 15, 2024
1 parent 1b057f5 commit 3ad1bc9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pip install conjugate-models
- [Built in Plotting](https://wd60622.github.io/conjugate/examples/plotting) with `plot_pdf` and `plot_pmf` methods
- [Vectorized Operations](https://wd60622.github.io/conjugate/examples/vectorized-inputs) for parameters and data
- [Indexing Parameters](https://wd60622.github.io/conjugate/examples/indexing) for subsetting and slicing
- [Generalized Numerical Inputs](https://wd60622.github.io/conjugate/examples/generalized-inputs) for inputs other than builtins and numpy arrays
- [Generalized Numerical Inputs](https://wd60622.github.io/conjugate/examples/generalized-inputs) for any inputs that act like numbers
- Out of box compatibility with `polars`, `pandas`, `numpy`, and more.
- [Unsupported Distributions](https://wd60622.github.io/conjugate/examples/pymc-sampling) for sampling from unsupported distributions

## Supported Models
Expand Down
25 changes: 23 additions & 2 deletions docs/examples/generalized-inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,30 @@ comments: true
---
# Generalized Numerical Inputs

Though the plotting is meant for numpy and python numbers, the conjugate models work with anything that works like numbers.
Conjugate models work with anything that works like numbers.

## Polars

For instance, Bayesian models with the Polars package:

```python
import polars as pl

# Data
df = pl.DataFrame({
"total": [10, 20, 50],
"successes": [5, 10, 25]
})

# Conjugate prior
prior = Beta(alpha=1, beta=1)
posterior = binomial_beta(n=df["total"], x=df["successes"], beta_prior=prior)

ax = posterior.plot_pdf(label=df["total"])
ax.legend(title="sample size")
```

![Polars Example](./../images/polars.png)

## Models with SQL

Expand Down Expand Up @@ -39,7 +61,6 @@ print("Posterior beta:", posterior.beta)
# Posterior beta: "previous_failures"-1+"total"-"successes"
```


## PyMC

Using PyMC distributions for sampling with additional uncertainty
Expand Down
Binary file added docs/images/polars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ pip install conjugate-models
- [Built in Plotting](examples/plotting.md) with `plot_pdf` and `plot_pmf` methods
- [Vectorized Operations](examples/vectorized-inputs.md) for parameters and data
- [Indexing Parameters](examples/indexing.md) for subsetting and slicing
- [Generalized Numerical Inputs](examples/generalized-inputs.md) for inputs other than builtins and numpy arrays
- [Generalized Numerical Inputs](examples/generalized-inputs.md) for any inputs that act like numbers
- Out of box compatibility with `polars`, `pandas`, `numpy`, and more.
- [Unsupported Distributions](examples/pymc-sampling.md) for sampling from unsupported distributions

## Supported Models
Expand Down

0 comments on commit 3ad1bc9

Please sign in to comment.