High-performance library for efficient ranking of large datasets using sparse comparison networks
Project description
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
- Decomposition: SNIC uses GBER to break down your dataset size into optimal subnetworks
- Matchup Generation: Creates structured groups of elements for comparison
- Sparse Comparisons: Each element participates in logarithmically few comparisons
- 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.
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 Distributions
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 snic-0.1.0.tar.gz.
File metadata
- Download URL: snic-0.1.0.tar.gz
- Upload date:
- Size: 48.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b27dd322518d5f32e135824f8cf9adcbf8964a0cc565b9d15aa5f08587b8917
|
|
| MD5 |
d6a6795e1e6edd11fd41c0d2de02a068
|
|
| BLAKE2b-256 |
8d656bd343623f587bb2f329099220bf3993bd4e13a13b6004f2c1529843a315
|
File details
Details for the file snic-0.1.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: snic-0.1.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 216.0 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbd50cea6e74969dbdd7807641904ee92455b0b9028dcedbb84db0dd3d97af4d
|
|
| MD5 |
45a53c2d1025b73d01f78219f52fac11
|
|
| BLAKE2b-256 |
de225b7662a2d652f6fc17bcf4321f2b904ca897f203bae2436f068d14458102
|
File details
Details for the file snic-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: snic-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 320.7 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06088101960dc791be3db7007bc509d265ef391f38318e5467c14817c53b85df
|
|
| MD5 |
3b22072bc4d78c56119e42313fab5eef
|
|
| BLAKE2b-256 |
09ebd2d8a52fdf40fc8fe041fe7c948f7f0059223f2d961421520161d3724d60
|
File details
Details for the file snic-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: snic-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 300.2 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa45895ce76448fa4cc3ae92fa4b4b0bc0c886ae4df4df9751734cc880b151fd
|
|
| MD5 |
b09e5eb162f37e8348387419410c25de
|
|
| BLAKE2b-256 |
1abdeb0bed4fdf25ee3590f0c61d0944dc2ff6f96746234a0b48f33d0964c0df
|
File details
Details for the file snic-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: snic-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 275.3 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcb17960a12cad98221c85d111b0f9e674ee7c3202ad42d66acec914cfb7bf1c
|
|
| MD5 |
2cb0f5d6dec4b111ac9f54578edc8477
|
|
| BLAKE2b-256 |
84337089e1d4d0064273544827eab3c157e4a1025f13b5e9611c526197dd017c
|
File details
Details for the file snic-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: snic-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 288.1 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48ce77d862b3bb7d0b13a4bffbfa7e9fed68cfd1e75b3ce68c00410b127d28e2
|
|
| MD5 |
e2c785520108a5eb44439fd7b0da66e7
|
|
| BLAKE2b-256 |
c1c83c0f835a04e7e23ca1b2d9ceb3c15264d000e3cc96ab6556b6d77d1eed55
|