Cloud cost prediction engine — framework-agnostic, strategy-based
Project description
billing-cost-prediction
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
- Architecture & Design — data flow, component diagram, design decisions
- Integration Guide — Django, SQL, CSV, custom strategies
- Strategy Guide — selection flowchart, tuning, per-strategy details
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-predictiontopyproject.tomldependencies - Create
backend/prediction/data_adapter.py(DB ↔ engine bridge) - Rewrite
task__multi_cloud_bill_predictusing engine + adapter - Change task from "delete-all + rebuild" to
update_or_createupsert - Add
unique_togetherconstraint 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 .
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 Distribution
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 billing_cost_prediction-0.1.1.tar.gz.
File metadata
- Download URL: billing_cost_prediction-0.1.1.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdb9f518459f56530ac9a4b2d671f6634264ab6336c38452951fb5237f8bbfb6
|
|
| MD5 |
dc2aff0fe5ac3982b1df11effa34a5d2
|
|
| BLAKE2b-256 |
aff5077fdb2ea5df0ff75dc6143e4b791c311b387badfb15ed7f4b61ca63fe13
|
Provenance
The following attestation bundles were made for billing_cost_prediction-0.1.1.tar.gz:
Publisher:
publish.yml on Visionary-Future/billing-cost-prediction
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
billing_cost_prediction-0.1.1.tar.gz -
Subject digest:
bdb9f518459f56530ac9a4b2d671f6634264ab6336c38452951fb5237f8bbfb6 - Sigstore transparency entry: 1583506689
- Sigstore integration time:
-
Permalink:
Visionary-Future/billing-cost-prediction@492ee89879fece86336928b70e4225f479abae8a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Visionary-Future
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@492ee89879fece86336928b70e4225f479abae8a -
Trigger Event:
push
-
Statement type:
File details
Details for the file billing_cost_prediction-0.1.1-py3-none-any.whl.
File metadata
- Download URL: billing_cost_prediction-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
534e3d5ee42f9283df12afc0741336028118fd7566d8115afba27624366b1a61
|
|
| MD5 |
721320ace2bf930f5208d2df6487f986
|
|
| BLAKE2b-256 |
23bab479813fc9ce484c37cba5a419402be49b1d61cda17187823d91e07500db
|
Provenance
The following attestation bundles were made for billing_cost_prediction-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Visionary-Future/billing-cost-prediction
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
billing_cost_prediction-0.1.1-py3-none-any.whl -
Subject digest:
534e3d5ee42f9283df12afc0741336028118fd7566d8115afba27624366b1a61 - Sigstore transparency entry: 1583506802
- Sigstore integration time:
-
Permalink:
Visionary-Future/billing-cost-prediction@492ee89879fece86336928b70e4225f479abae8a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Visionary-Future
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@492ee89879fece86336928b70e4225f479abae8a -
Trigger Event:
push
-
Statement type: