Skip to main content

Clear BOW 📚

License: MIT

Lightweight dictionary-based classifier that converts word frequencies into label probabilities using softmax/sigmoid functions. Perfect for bootstrapping classifications with terminology lists.

Features

  • 🔍 Dictionary-based classification
  • 📊 Multi-class (softmax) support
  • 🏷️ Multi-label (sigmoid) support
  • 📝 Simple terminology lists
  • 🔢 Probability outputs
  • 💾 Model save/load functionality
  • 🎯 93% test coverage

Installation

# Via pip
pip install clear-bow

# Or from source
git clone https://github.com/samhardyhey/clear-bow
cd clear-bow
pip install -e .

Usage

from clear_bow.classifier import DictionaryClassifier

# Define your dictionary
super_dict = {
    "regulation": ["asic", "government", "federal", "tax"],
    "contribution": ["contribution", "concession", "personal", "after tax"],
    "fund": ["unisuper", "aus super", "sun super", "qsuper"],
}

# Create classifier (multi-class by default)
dc = DictionaryClassifier(label_dictionary=super_dict)

# Or for multi-label classification
dc = DictionaryClassifier(
    label_dictionary=super_dict,
    classifier_type="multi_label"
)

# Make predictions
result = dc.predict_single("A 10% contribution to your super fund")
# Returns probability distribution across labels

# Batch predictions
results = dc.predict_batch([
    "A 10% contribution to your super fund",
    "Government regulation of super funds"
])

# Save model to disk
dc.to_disk("path/to/model")

# Load model from disk
dc = DictionaryClassifier()
dc.from_disk("path/to/model")

Development

# Setup development environment
make setup-local-dev
source venv/bin/activate

# Run tests
make test-local

# Run tests with coverage
make test-coverage

# Multi-environment testing
make test-tox

# Build distribution
make dist-bundle-build

# Clean build artifacts
make clean

# Upload to PyPI
make publish

Project Structure

clear-bow/
├── src/
│   └── clear_bow/
│       ├── __init__.py
│       └── classifier.py
├── tests/
│   ├── conftest.py
│   └── test_classifier.py
├── pyproject.toml    # Project configuration
├── tox.ini          # Multi-environment testing
└── makefile         # Development commands

Features in Detail

Multi-class Classification

  • Uses softmax transformation
  • Outputs sum to 1.0
  • Best for mutually exclusive categories

Multi-label Classification

  • Uses sigmoid transformation
  • Each label gets independent probability
  • Best for non-exclusive categories

Error Handling

  • Validates classifier types
  • Handles missing/invalid files
  • Provides informative error messages

File Operations

  • Save model configuration
  • Save label dictionaries
  • Load models from disk

Note: See tests for additional usage examples and edge cases.

License

MIT License - See LICENSE file for details.

Metadata

Release files for clear-bow 1.0.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 clear-bow 1.0.0
File Size Uploaded Provenance Actions
clear_bow-1.0.0.tar.gz 14.1 kB Without provenance Details for clear_bow-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clear-bow 1.0.0
File Interpreter ABI Platform Actions
clear_bow-1.0.0-py3-none-any.whl Python 3 none any Details for clear_bow-1.0.0-py3-none-any.whl

Total release size: 21.1 kB

Release files / clear_bow-1.0.0.tar.gz

Download URL clear_bow-1.0.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fb634865e5f12dd68759bf597113d6c85b8866f67acd0100072e6e4067e3d860
BLAKE2b-256 checksum
How to use checksums
4141466803e1712955b575d400fa3a076b8902e45048552236a043cd006e3d29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release files / clear_bow-1.0.0-py3-none-any.whl

Download URL clear_bow-1.0.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1a70831aa358149ddf8c44e5c79b10f09adbfef5b83c914fbc6e9ec292935e6
BLAKE2b-256 checksum
How to use checksums
0c96f37f7c3221cbde995ebd986dd2f9a496b5726d0d9777ee5a9f8e6a742cfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Security for clear-bow 1.0.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

1.0.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