Skip to main content

billing-cost-prediction

Tests Python Coverage

Framework-agnostic cloud cost prediction engine. Strategy-based, zero dependencies.

Quick Start

from billing_cost_prediction import PredictionEngine, BillingRecord, BillingMonth, CloudProvider

engine = PredictionEngine()
records = [
    BillingRecord(
        resource_id="res-001",
        cloud_provider=CloudProvider.AZURE,
        billing_month=BillingMonth.from_string("2026-04"),
        cost=1234.56,
    ),
]
results = engine.predict(records, months=12)
for batch in results:
    for r in batch.results:
        print(f"{r.predict_month}: {r.predicted_cost:.2f} ({r.method}, confidence={r.confidence})")

Strategies

Strategy Best For Min History
moving_average Stable workloads 1 month
exponential_smoothing Noisy data, recent-weighted 2 months
linear_trend Consistent growth/decline 3 months
seasonal Annual recurring patterns 12 months
auto (default) Picks best based on data —

→ Strategy guide with flowcharts

Docs

Roadmap

✅ Phase 1: Core Engine (done)

  • Type system (BillingRecord, PredictionResult, BillingMonth, enums)
  • 4 strategies: moving_average, exponential_smoothing, linear_trend, seasonal
  • Back-test based confidence scoring
  • Per-resource auto strategy selection
  • Extensible strategy protocol (Protocol, structural subtyping)
  • Unit + integration tests (95%+ coverage)
  • Architecture refactoring (O(n) iteration, sort-once, build_result helper)
  • Python 3.10+ support
  • Architecture docs with flowcharts (Mermaid)
  • Pre-commit hooks (ruff + mypy)

🔜 Phase 2: Production Readiness (next)

  • PyPI publish (pip install cost-prediction)
  • CI pipeline (GitHub Actions: pytest/ruff/mypy matrix)
  • Coverage reporting (sticky PR comment)
  • Integration guide (Django, SQL, CSV, custom strategy)

🔗 Django Integration (cross-repo)

Repo: softwareone-finops-backend

  • Remove backend/prediction/prediction_model/ directory
  • Remove backend/prediction/azure_views.py (dead code)
  • Add cost-prediction to pyproject.toml dependencies
  • Create backend/prediction/data_adapter.py (DB ↔ engine bridge)
  • Rewrite task__multi_cloud_bill_predict using engine + adapter
  • Change task from "delete-all + rebuild" to update_or_create upsert
  • Add unique_together constraint on prediction model
  • Remove unused model fields (billing_model, region, availability_zone, provider_metadata)
  • Unify actual-cost queries across Alibaba/Azure in Views
  • Integration tests for data_adapter, tasks, views

🔮 Phase 3: Algorithm Enhancements (done)

  • ExponentialSmoothingStrategy
  • CostAnomalyDetector (pre-filter anomalous months)
  • StrategyEnsemble (multi-strategy voting)
  • Prediction accuracy tracking (MAPE)
  • Day-based billing normalization (to_daily_rates / to_monthly_rates)

Development

# install in dev mode
pip install -e ".[dev]"

# run tests
pytest -v

# lint
ruff check .
mypy .

Metadata

Release files for billing-cost-prediction 0.1.1

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

Source distribution (sdist)

Source distribution for billing-cost-prediction 0.1.1
File Size Uploaded Provenance Actions
billing_cost_prediction-0.1.1.tar.gz 28.0 kB With provenance Details for billing_cost_prediction-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for billing-cost-prediction 0.1.1
File Interpreter ABI Platform Actions
billing_cost_prediction-0.1.1-py3-none-any.whl Python 3 none any Details for billing_cost_prediction-0.1.1-py3-none-any.whl

Total release size: 47.0 kB

Release files / billing_cost_prediction-0.1.1.tar.gz

Download URL billing_cost_prediction-0.1.1.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bdb9f518459f56530ac9a4b2d671f6634264ab6336c38452951fb5237f8bbfb6
BLAKE2b-256 checksum
How to use checksums
aff5077fdb2ea5df0ff75dc6143e4b791c311b387badfb15ed7f4b61ca63fe13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 20, 2026.

Transparency log

Release files / billing_cost_prediction-0.1.1-py3-none-any.whl

Download URL billing_cost_prediction-0.1.1-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
534e3d5ee42f9283df12afc0741336028118fd7566d8115afba27624366b1a61
BLAKE2b-256 checksum
How to use checksums
23bab479813fc9ce484c37cba5a419402be49b1d61cda17187823d91e07500db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 20, 2026.

Transparency log

Security for billing-cost-prediction 0.1.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for billing_cost_prediction-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 20, 2026.

Transparency log

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.1 This release

2 release files Full 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