From Play to Proof. Run experiments, then crystallize your findings.
Project description
Crystallize
From Play to Proof.
Run experiments. Start exploring, then crystallize your findings with a hypothesis.
pip install crystallize-ml
Quick Start
Exploratory Mode
Just play around. No ceremony.
from crystallize import run
def play_game(config, ctx):
# Your logic here
winner = "treatment" if config["power"] > 5 else "baseline"
ctx.record("win", 1 if winner == "treatment" else 0)
return {"winner": winner}
results = run(
fn=play_game,
configs={
"weak": {"power": 2},
"strong": {"power": 10},
},
replicates=5,
)
Output:
⚠ Exploratory mode — perfect for playing around.
When ready to prove something: hypothesis="a.x > b.x"
Results:
weak:
win: [0, 0, 0, 0, 0] → μ=0.00
strong:
win: [1, 1, 1, 1, 1] → μ=1.00
Confirmatory Mode
You noticed something. Now prove it.
results = run(
fn=play_game,
configs={
"weak": {"power": 2},
"strong": {"power": 10},
},
replicates=20,
hypothesis="strong.win > weak.win",
seed=42,
)
Output:
✓ Confirmatory mode
Hypothesis: strong.win > weak.win
Seed: 42
✓ Hypothesis SUPPORTED
strong.win (μ=1.00, n=20) > weak.win (μ=0.00, n=20)
Effect size: 1.00, p=0.000
The API
from crystallize import run
results = run(
fn=my_function, # Your function: fn(config) or fn(config, ctx)
configs={...}, # {"name": {config_dict}, ...}
replicates=10, # How many times to run each config
seed=42, # For reproducibility
hypothesis="a.x > b.x", # Triggers confirmatory mode
on_event=callback, # For live UIs (viewer integration)
progress=True, # Show progress bar
)
Recording Metrics
def my_function(config, ctx):
result = do_something(config)
# Record metrics for analysis
ctx.record("accuracy", result.accuracy)
ctx.record("latency", result.latency, tags={"unit": "ms"})
return result
Hypothesis Syntax
# Config A's metric > Config B's metric
hypothesis="treatment.accuracy > baseline.accuracy"
# Less than
hypothesis="fast.latency < slow.latency"
# Greater than or equal
hypothesis="new.score >= old.score"
Results
results = run(...)
# Raw return values
results.results["config_name"] # [result1, result2, ...]
# Recorded metrics
results.metrics["config_name"]["metric_name"] # [val1, val2, ...]
# Hypothesis result (if provided)
results.hypothesis_result.supported # True/False
results.hypothesis_result.p_value # Statistical significance
# Save results
results.to_json("results.json")
Live Updates
def on_event(event):
if event["type"] == "metric":
print(f"{event['config']}: {event['metric']} = {event['value']}")
results = run(
fn=my_function,
configs={...},
on_event=on_event,
)
Philosophy
- No ceremony for exploration — Just run the function with configs
- Same code, more rigor — Add
hypothesis=to crystallize, don't rewrite - Hypothesis as pre-registration — Commit before seeing results
- Statistical output built-in — p-values, effect sizes, not just means
Install
# Basic (no statistical tests, just mean comparison)
pip install crystallize-ml
# With statistical tests (scipy)
pip install crystallize-ml[stats]
v0.x Legacy
Looking for the old framework with pipelines, treatments, and plugins? See the legacy/v0.x branch.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crystallize_ml-1.0.0a1.tar.gz.
File metadata
- Download URL: crystallize_ml-1.0.0a1.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c43c841db136017ff2e5b46e144ea54829872bbfb187d0941745a580261af2c
|
|
| MD5 |
886e157d96c821ea3560c42058053d2b
|
|
| BLAKE2b-256 |
0c543717e3c89119ca38fbd2a4ff6cc43da777c58f5ba36f51d5753b0f5c8d34
|
Provenance
The following attestation bundles were made for crystallize_ml-1.0.0a1.tar.gz:
Publisher:
publish_pypi.yml on brysontang/crystallize
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crystallize_ml-1.0.0a1.tar.gz -
Subject digest:
5c43c841db136017ff2e5b46e144ea54829872bbfb187d0941745a580261af2c - Sigstore transparency entry: 792559864
- Sigstore integration time:
-
Permalink:
brysontang/crystallize@a75c38a1e5c890f22e7207edea7d5b26423fa16d -
Branch / Tag:
refs/tags/crystallize-ml@v1.0.0-alpha.1 - Owner: https://github.com/brysontang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@a75c38a1e5c890f22e7207edea7d5b26423fa16d -
Trigger Event:
release
-
Statement type:
File details
Details for the file crystallize_ml-1.0.0a1-py3-none-any.whl.
File metadata
- Download URL: crystallize_ml-1.0.0a1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fffaf3d2dcd11e92b23a7e49f4ec757c76c653c7a806268c981a576e15cceee
|
|
| MD5 |
bafab8838dd9dbfbb394e340d1db28a9
|
|
| BLAKE2b-256 |
775be289dccd8482771ccd7b774b76a28ee92e5c5075cc80939ebb1f70df67bf
|
Provenance
The following attestation bundles were made for crystallize_ml-1.0.0a1-py3-none-any.whl:
Publisher:
publish_pypi.yml on brysontang/crystallize
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crystallize_ml-1.0.0a1-py3-none-any.whl -
Subject digest:
7fffaf3d2dcd11e92b23a7e49f4ec757c76c653c7a806268c981a576e15cceee - Sigstore transparency entry: 792559923
- Sigstore integration time:
-
Permalink:
brysontang/crystallize@a75c38a1e5c890f22e7207edea7d5b26423fa16d -
Branch / Tag:
refs/tags/crystallize-ml@v1.0.0-alpha.1 - Owner: https://github.com/brysontang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@a75c38a1e5c890f22e7207edea7d5b26423fa16d -
Trigger Event:
release
-
Statement type: