Skip to main content

A powerful tool for analyzing leading indicators and setting optimal thresholds

Project description

LeadIndicator

A Python package for analyzing leading indicators and finding optimal thresholds.

Features

  • Analyze time series data to identify leading indicators
  • Find optimal thresholds using multiple metrics
  • Generate comprehensive analysis reports
  • Support for categorical analysis
  • Beautiful visualizations
  • Polars-based for high performance

Installation

pip install leadindicator

Quick Start

import polars as pl
from leadindicator import ThresholdAnalyzer

# Load your data
df = pl.read_excel("your_data.xlsx")

# Create analyzer
analyzer = ThresholdAnalyzer(
    score_column="score",
    target_column="event",
    category_column="category"  # Optional
)

# Run analysis
results = analyzer.analyze(df)

# Generate report
analyzer.save_report("analysis_report.html")

Example: Fruit Spoilage Analysis

The package includes an example that demonstrates how to use LeadIndicator to analyze fruit spoilage data:

from leadindicator import ThresholdAnalyzer
import polars as pl

# Load example data
df = pl.read_excel("Test Data.xlsx")

# Create analyzer
analyzer = ThresholdAnalyzer(
    score_column="Ethylene",
    target_column="Spoiled",
    category_column="Fruit Type"
)

# Run analysis
results = analyzer.analyze(df)

# Save report
analyzer.save_report("fruit_spoilage_analysis.html")

# Access results programmatically
best_threshold = results[0]
print(f"Best threshold: {best_threshold.threshold}")
print(f"Balanced accuracy: {best_threshold.balanced_accuracy:.2%}")
print(f"Capture rate: {best_threshold.capture_rate:.1f}%")
print(f"Event probability: {best_threshold.event_probability:.1f}%")

Documentation

For detailed documentation, visit docs/.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

leadindicator-0.1.1.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leadindicator-0.1.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file leadindicator-0.1.1.tar.gz.

File metadata

  • Download URL: leadindicator-0.1.1.tar.gz
  • Upload date:
  • Size: 32.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for leadindicator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4dedd50adf3fc036227b5a2fc519f94b5f4d2a388c0fe97aa9341b6af1b12493
MD5 b4a38cb37ccbdfaff14bba1293512097
BLAKE2b-256 2d18ac278704b084f0754f44400861667193c95d5322070bfe8f6f16c21f13c3

See more details on using hashes here.

File details

Details for the file leadindicator-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: leadindicator-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for leadindicator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f32ceeb2ba53806509e3db9e9305f85af5b3f6aa3ff7b50aa21758589c76c06
MD5 572c172ee374cfc18d17064265c5c991
BLAKE2b-256 47b1cfaead27b854c2554cb91d85c5d70969989514e29c5a6fc91a76bd5df2d5

See more details on using hashes here.

Supported by

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