Skip to main content

Distilled

A data stream reduction middleware that intelligently reduces large multivariate data streams to representative subsets while maintaining proportional characteristics.

Overview

Distilled uses spatial vector analysis and A/B testing strategies to continuously analyze streaming data and pass along a configurable percentage (default 10%) that accurately represents the full dataset's characteristics across a sliding time window.

Key Features

  • Proportional Representation: Maintains statistical accuracy of multivariate characteristics
  • Sliding Time Window: Configurable time horizon (60-3600 seconds) for analysis
  • Extensible Design: Object-oriented architecture with customizable grading functions
  • Generator/Coroutine Pattern: Efficient streaming data processing
  • Real-time Processing: Optimized for high-throughput data streams

How It Works

  1. Data Ingestion: Receives batches of raw data points
  2. Vector Evaluation: Applies grading functions to extract characteristics
  3. Proportion Analysis: Calculates current vs. sent data proportions
  4. Optimal Selection: Uses vector analysis to select representative subset
  5. Time Horizon Management: Maintains FIFO queues with automatic cleanup

Architecture

Raw Data Stream → Grading Functions → Vector Analysis → Optimal Selection → Reduced Stream
                     ↓                    ↓               ↓
                 DataPoints         Proportions      Time Horizon
                                   Comparison        Management

Installation

pip install -r requirements.txt

Quick Start

from distilled import DistilledProcessor, NumericGrader, CategoricalGrader

# Define how to evaluate your data characteristics
grading_functions = {
    "age": NumericGrader("age", lambda person: float(person.age)),
    "gender": CategoricalGrader("gender", ["male", "female", "other"], 
                               lambda person: person.gender.lower()),
    "income": NumericGrader("income", lambda person: person.income)
}

# Create processor
processor = DistilledProcessor(
    grading_functions=grading_functions,
    time_horizon_seconds=3600,  # 1 hour window
    reduction_percentage=0.1,   # 10% pass-through
    batch_size=100
)

# Process data batches
batch_data = get_your_data_batch()  # Your data source
selected_points = processor.process_batch(batch_data)

# selected_points now contains ~10% of input that best represents full dataset

Core Classes

DistilledProcessor

Main processor class implementing the generator/coroutine pattern:

  • process_batch(): Process a batch and return selected subset
  • get_current_stats(): Get current proportion statistics
  • reset(): Reset processor state

DataPoint

Represents individual data points with metadata:

  • data: Raw data payload
  • timestamp: Processing timestamp
  • vector_values: Evaluated characteristics
  • sent_previously: Tracking flag

Grading Functions

Define how to evaluate data characteristics:

  • NumericGrader: Extracts numerical values
  • CategoricalGrader: Classifies into predefined categories
  • LambdaGrader: Quick wrapper for simple functions

Selection Algorithm

The core algorithm works as follows:

  1. Gap Analysis: Calculate representation gaps between current and sent data
  2. Point Scoring: Score each candidate point's improvement potential
  3. Greedy Selection: Select points that best minimize representation gaps
  4. Tie Breaking: Prioritize smallest proportional buckets first
  5. Update Tracking: Maintain sent data proportions for next iteration

Configuration

Time Horizon

Controls how long data is retained for analysis:

processor = DistilledProcessor(
    grading_functions=functions,
    time_horizon_seconds=1800  # 30 minutes
)

Reduction Percentage

Controls what percentage of data passes through:

processor = DistilledProcessor(
    grading_functions=functions,
    reduction_percentage=0.05  # 5% pass-through
)

Batch Size

Controls internal processing batch size:

processor = DistilledProcessor(
    grading_functions=functions,
    batch_size=50  # Smaller batches
)

Examples

See examples/basic_usage.py for a complete working example with sample data.

Testing

Run tests with:

python -m pytest tests/

Or run individual test files:

python tests/test_basic.py

Development Status

Current Status: Architecture and API design complete with method stubs.

Next Steps:

  1. Implement grading function evaluation
  2. Implement proportion calculation algorithms
  3. Implement vector analysis and selection logic
  4. Implement time horizon management
  5. Add comprehensive testing
  6. Performance optimization

Contributing

This is an open source project. Contributions are welcome!

License

MIT License - see LICENSE file for details.


Distilled - Intelligent data stream reduction for the modern data pipeline.

Metadata

Release files for distilled 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for distilled 0.1.0
File Size Uploaded Provenance
distilled-0.1.0.tar.gz 29.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for distilled 0.1.0
File Interpreter ABI Platform
distilled-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.0 kB

Release files / distilled-0.1.0.tar.gz

Download URL distilled-0.1.0.tar.gz
Size 29.2 kB
Tags Source
SHA-256 checksum
How to use checksums
effe675a3313dd5fc1ce9d2ec29000a4950aa58f9beb403c91be04cdcb096606
BLAKE2b-256 checksum
How to use checksums
82fba06beb52bf0410ce7df6ea1aeee443cfb58497775991d1c057c55eca3158
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Release files / distilled-0.1.0-py3-none-any.whl

Download URL distilled-0.1.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a374487e54de7fb6759cf1d7755ae15fe2aaffdc77cbd48427b7ac2deba076a
BLAKE2b-256 checksum
How to use checksums
3f851858a947e2a89515847a1970a972d9fc77d7d0e23efeb173f26f2733d9bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Security for distilled 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page