Skip to main content

A lightweight Python library for reproducible experiments

Project description

๐Ÿงช RexF - Smart Experiments Framework

CI CodeQL PyPI Python Versions License: MIT

A lightweight Python library for reproducible computational experiments with an ultra-simple, smart API. From idea to insight in under 5 minutes, with zero configuration.

โœจ Key Features

  • ๐ŸŽฏ Ultra-Simple API: Single @experiment decorator - that's it!
  • ๐Ÿš€ Auto-Everything: Parameters, metrics, and results detected automatically
  • ๐Ÿ” Smart Exploration: Automated parameter space exploration with multiple strategies
  • ๐Ÿ’ก Intelligent Insights: Automated pattern detection and recommendations
  • ๐Ÿ“Š Web Dashboard: Beautiful real-time experiment monitoring
  • ๐Ÿ”ง CLI Analytics: Powerful command-line tools for ad-hoc analysis
  • ๐Ÿ“ˆ Query Interface: Find experiments using simple expressions like "accuracy > 0.9"
  • ๐Ÿ”„ Reproducible: Git commit tracking, environment capture, seed management
  • ๐Ÿ’พ Local-First: SQLite database - no external servers required

๐Ÿš€ Quick Start

Installation

pip install rexf

Ultra-Simple Usage

from rexf import experiment, run

@experiment
def my_experiment(learning_rate, batch_size=32):
    # Your experiment code here
    accuracy = train_model(learning_rate, batch_size)
    return {"accuracy": accuracy, "loss": 1 - accuracy}

# Run single experiment
run.single(my_experiment, learning_rate=0.01, batch_size=64)

# Get insights
print(run.insights())

# Find best experiments
best = run.best(metric="accuracy", top=5)

# Auto-explore parameter space
run.auto_explore(my_experiment, strategy="random", budget=20)

# Launch web dashboard
run.dashboard()

๐ŸŽฏ Core Philosophy

From idea to insight in under 5 minutes, with zero configuration.

RexF prioritizes user experience over architectural purity. Instead of making you learn complex APIs, it automatically detects what you're doing and provides smart features to accelerate your research.

๐Ÿ“– Comprehensive Example

import math
import random
from rexf import experiment, run

@experiment
def estimate_pi(num_samples=10000, method="uniform"):
    """Estimate ฯ€ using Monte Carlo methods."""
    inside_circle = 0
    
    for _ in range(num_samples):
        x, y = random.uniform(-1, 1), random.uniform(-1, 1)
        if x*x + y*y <= 1:
            inside_circle += 1
    
    pi_estimate = 4 * inside_circle / num_samples
    error = abs(pi_estimate - math.pi)
    
    return {
        "pi_estimate": pi_estimate,
        "error": error,
        "accuracy": 1 - (error / math.pi)
    }

# Run experiments
run.single(estimate_pi, num_samples=50000, method="uniform")
run.single(estimate_pi, num_samples=100000, method="stratified")

# Auto-explore to find best parameters
run_ids = run.auto_explore(
    estimate_pi,
    strategy="grid", 
    budget=10,
    optimization_target="accuracy"
)

# Get smart insights
insights = run.insights()
print(f"Success rate: {insights['summary']['success_rate']:.1%}")

# Find high-accuracy runs
accurate_runs = run.find("accuracy > 0.99")

# Compare experiments
run.compare(run.best(top=3))

# Launch web dashboard
run.dashboard()  # Opens http://localhost:8080

๐Ÿ”ง Advanced Features

Smart Parameter Exploration

# Random exploration
run.auto_explore(my_experiment, strategy="random", budget=20)

# Grid search
run.auto_explore(my_experiment, strategy="grid", budget=15)

# Adaptive exploration (learns from results)
run.auto_explore(my_experiment, strategy="adaptive", budget=25, 
                optimization_target="accuracy")

Query Interface

# Find experiments using expressions
high_acc = run.find("accuracy > 0.9")
fast_runs = run.find("duration < 30")
recent_good = run.find("accuracy > 0.8 and start_time > '2024-01-01'")

# Query help
run.query_help()

Experiment Suggestions

# Get next experiment suggestions
suggestions = run.suggest(
    my_experiment, 
    count=5, 
    strategy="balanced",  # "exploit", "explore", or "balanced"
    optimization_target="accuracy"
)

for suggestion in suggestions["suggestions"]:
    print(f"Try: {suggestion['parameters']}")
    print(f"Reason: {suggestion['reasoning']}")

CLI Analytics

Analyze experiments from the command line:

# Show summary
rexf-analytics --summary

# Query experiments
rexf-analytics --query "accuracy > 0.9"

# Generate insights
rexf-analytics --insights

# Compare best experiments
rexf-analytics --compare --best 5

# Export to CSV
rexf-analytics --list --format csv --output results.csv

Web Dashboard

Launch a beautiful web interface:

run.dashboard()  # Opens http://localhost:8080

Features:

  • ๐Ÿ“Š Real-time experiment monitoring
  • ๐Ÿ” Interactive filtering and search
  • ๐Ÿ’ก Automated insights generation
  • ๐Ÿ“ˆ Statistics overview and trends
  • ๐ŸŽฏ Experiment comparison tools

๐ŸŽจ Why RexF?

Before (Traditional Approach)

import mlflow
import sacred
from sacred import Experiment

# Complex setup required
ex = Experiment('my_exp')
mlflow.set_tracking_uri("...")

@ex.config
def config():
    learning_rate = 0.01
    batch_size = 32

@ex.automain
def main(learning_rate, batch_size):
    with mlflow.start_run():
        # Your code here
        mlflow.log_param("lr", learning_rate)
        mlflow.log_metric("accuracy", accuracy)

After (RexF)

from rexf import experiment, run

@experiment
def my_experiment(learning_rate=0.01, batch_size=32):
    # Your code here - that's it!
    return {"accuracy": accuracy}

run.single(my_experiment, learning_rate=0.05)

Key Differences

Feature Traditional Tools RexF
Setup Complex configuration Single decorator
Parameter Detection Manual logging Automatic
Metric Tracking Manual logging Automatic
Insights Manual analysis Auto-generated
Exploration Write custom loops run.auto_explore()
Comparison Custom dashboards run.compare()
Querying SQL/Complex APIs run.find("accuracy > 0.9")

๐Ÿ› ๏ธ Architecture

RexF uses a plugin-based architecture:

rexf/
โ”œโ”€โ”€ core/           # Core experiment logic
โ”œโ”€โ”€ backends/       # Storage implementations (SQLite, etc.)
โ”œโ”€โ”€ intelligence/   # Smart features (insights, exploration)
โ”œโ”€โ”€ dashboard/      # Web interface
โ”œโ”€โ”€ cli/           # Command-line tools
โ””โ”€โ”€ plugins/       # Extensions (export, visualization)

Backends

  • SQLiteStorage: Fast local storage (default)
  • IntelligentStorage: Enhanced analytics and querying
  • FileSystemArtifacts: Local artifact management

Intelligence Modules

  • ExplorationEngine: Automated parameter space exploration
  • InsightsEngine: Pattern detection and recommendations
  • SuggestionEngine: Next experiment recommendations
  • SmartQueryEngine: Natural language-like querying

๐Ÿ“Š Data Storage

RexF automatically captures:

  • Experiment metadata: Name, timestamp, duration, status
  • Parameters: Function arguments and defaults
  • Results: Return values (auto-categorized as metrics/results/artifacts)
  • Environment: Git commit, Python version, dependencies
  • Reproducibility: Random seeds, system info

All data is stored locally in SQLite with no external dependencies.

๐Ÿ”„ Reproducibility

RexF ensures reproducibility by automatically tracking:

  • Code version: Git commit hash and diff
  • Environment: Python version, installed packages
  • Parameters: All function arguments and defaults
  • Random seeds: Automatic seed capture and restoration
  • System info: OS, hardware, execution environment

๐Ÿšง Roadmap

  • โœ… Phase 1: Simple API and smart features
  • โœ… Phase 2: Auto-exploration and insights
  • โœ… Phase 3: Web dashboard and CLI tools
  • ๐Ÿ”„ Phase 4: Advanced optimization and ML integration
  • ๐Ÿ“‹ Phase 5: Cloud sync and collaboration features

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

git clone https://github.com/dhruv1110/rexf.git
cd rexf
pip install -e ".[dev]"
pre-commit install

Running Tests

pytest tests/ -v --cov=rexf

๐Ÿ“„ License

MIT License - see LICENSE for details.

๐Ÿ”— Links


Made with โค๏ธ for researchers who want to focus on science, not infrastructure.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rexf-0.1.0.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

rexf-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file rexf-0.1.0.tar.gz.

File metadata

  • Download URL: rexf-0.1.0.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rexf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea91606a2d050e7dbf32c88682c150b1237734815bfea03de21b077dd1f252fe
MD5 4c73949a4d7b3b59f2b5a8bec32aab91
BLAKE2b-256 e1dbb1a56b60fcc83b95e13e68af1e4f99a414ccf1afac20ff49acb34700ea92

See more details on using hashes here.

File details

Details for the file rexf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rexf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rexf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70bf6d7bb6ddcfcf77b35766f7381fc9fe524ba01237f649b6d6f48ca6d6e1ed
MD5 3e021baecaf150aec930fe8b94f04992
BLAKE2b-256 78808f95656c722d6f1ec818ccec1a1121607af2b103002f1ffc012d4398faf4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page