Skip to main content

SNIC: Sparse Network of Idempotent Comparisons

A high-performance Python library for efficient ranking of large datasets using sparse comparison networks.

What is SNIC?

SNIC is a novel ranking algorithm that dramatically reduces the number of comparisons needed to rank large sets of elements. Instead of requiring O(n²) pairwise comparisons like traditional methods, SNIC achieves O(n log n) efficiency through:

  • Sparse Networks: Structured comparison networks that capture ranking information with minimal comparisons
  • Base-sized Matchups: Fixed-size groups that maximize information extraction per comparison
  • GBER Foundation: Mathematical framework using Generalized Base Exponential Representation for optimal network structure

Key Benefits

  • Scalable: Efficiently handles datasets from hundreds to millions of elements
  • Sparse: Requires far fewer comparisons than traditional ranking methods
  • Structured: Deterministic, mathematically-grounded approach to comparison generation
  • Fast: High-performance Rust implementation with Python bindings

Quick Start

pip install snic
import snic

# Generate matchups for ranking 100 elements with base-3 comparisons
matchups = snic.stream_matches_from(100, 3)

# Each matchup contains 3 elements to be ranked
print(f"Generated {len(matchups)} matchups")
print(f"First matchup: {matchups[0]}")  # e.g., [0, 33, 67]

# After ranking each matchup externally (by human judgment, ML model, etc.)
# Convert ranked matchups back to final ranking
ranked_matchups = [
    [1, 0, 2],  # Example: element 1 ranked first, 0 second, 2 third
    [4, 3, 5],  # Continue for all matchups...
    # ... 
]

final_ranking = snic.stream_rankings_from(ranked_matchups)
print(f"Final ranking: {final_ranking}")

How It Works

  1. Decomposition: SNIC uses GBER to break down your dataset size into optimal subnetworks
  2. Matchup Generation: Creates structured groups of elements for comparison
  3. Sparse Comparisons: Each element participates in logarithmically few comparisons
  4. Ranking Synthesis: Combines local rankings into a global result

Use Cases

  • Large-scale surveys: Rank thousands of items with minimal human effort
  • Content recommendation: Efficiently determine user preferences
  • Tournament systems: Fair bracket generation for competitions
  • Data analysis: Rank features, samples, or model outputs at scale

Development

Local Setup

# Clone the repository
git clone https://github.com/ryzhakar/snic-rs
cd snic-rs

# Install development dependencies
pip install maturin

# Build and install in development mode
maturin develop

# Run tests
python -m pytest

Building

# Build wheel
maturin build --release

# Build and publish to PyPI
maturin publish

Algorithm Details

SNIC is based on rigorous mathematical foundations:

  • GBER (Generalized Base Exponential Representation): Decomposes dataset sizes into optimal subnetwork structures
  • Stride-based Matchup Generation: Ensures comprehensive coverage with minimal redundancy
  • Hub-and-Spoke Connectivity: Connects subnetworks for global ranking consistency

For detailed algorithm documentation, see the wiki.

Performance

SNIC's efficiency scales logarithmically:

Dataset Size Traditional Comparisons SNIC Comparisons Reduction
1,000 499,500 ~3,000 99.4%
10,000 49,995,000 ~40,000 99.9%
100,000 4,999,950,000 ~500,000 99.99%

License

AGPLv3 License - see LICENSE for details.

Metadata

Release files for snic 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 snic 0.1.0
File Size Uploaded Provenance Actions
snic-0.1.0.tar.gz 48.2 kB Without provenance Details for snic-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for snic 0.1.0
File Actions
snic-0.1.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for snic-0.1.0-cp38-abi3-win_amd64.whl
snic-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for snic-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
snic-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for snic-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
snic-0.1.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for snic-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
snic-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for snic-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 1.4 MB

Release files / snic-0.1.0.tar.gz

Download URL snic-0.1.0.tar.gz
Size 48.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5b27dd322518d5f32e135824f8cf9adcbf8964a0cc565b9d15aa5f08587b8917
BLAKE2b-256 checksum
How to use checksums
8d656bd343623f587bb2f329099220bf3993bd4e13a13b6004f2c1529843a315
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.3

Release files / snic-0.1.0-cp38-abi3-win_amd64.whl

Download URL snic-0.1.0-cp38-abi3-win_amd64.whl
Size 216.0 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
bbd50cea6e74969dbdd7807641904ee92455b0b9028dcedbb84db0dd3d97af4d
BLAKE2b-256 checksum
How to use checksums
de225b7662a2d652f6fc17bcf4321f2b904ca897f203bae2436f068d14458102
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.3

Release files / snic-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL snic-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 320.7 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
06088101960dc791be3db7007bc509d265ef391f38318e5467c14817c53b85df
BLAKE2b-256 checksum
How to use checksums
09ebd2d8a52fdf40fc8fe041fe7c948f7f0059223f2d961421520161d3724d60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.3

Release files / snic-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL snic-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 300.2 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
fa45895ce76448fa4cc3ae92fa4b4b0bc0c886ae4df4df9751734cc880b151fd
BLAKE2b-256 checksum
How to use checksums
1abdeb0bed4fdf25ee3590f0c61d0944dc2ff6f96746234a0b48f33d0964c0df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.3

Release files / snic-0.1.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL snic-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Size 275.3 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bcb17960a12cad98221c85d111b0f9e674ee7c3202ad42d66acec914cfb7bf1c
BLAKE2b-256 checksum
How to use checksums
84337089e1d4d0064273544827eab3c157e4a1025f13b5e9611c526197dd017c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.3

Release files / snic-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL snic-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 288.1 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
48ce77d862b3bb7d0b13a4bffbfa7e9fed68cfd1e75b3ce68c00410b127d28e2
BLAKE2b-256 checksum
How to use checksums
c1c83c0f835a04e7e23ca1b2d9ceb3c15264d000e3cc96ab6556b6d77d1eed55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.3

Security for snic 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

6 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