Metadata-Version: 2.4
Name: databubble-scoring
Version: 0.1.0
Summary: Pure scoring/replay logic for DataBubble model cards, scorecards, and segment scorers — no network calls, no platform dependency.
Author: DataBubble AI
License-Expression: MIT
Project-URL: Homepage, https://databubble.ai
Keywords: statistics,machine learning,mlflow,model scoring
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=1.5
Requires-Dist: scipy>=1.10
Requires-Dist: pydantic>=2.0
Provides-Extra: mlflow
Requires-Dist: mlflow>=2.10; extra == "mlflow"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: mlflow>=2.10; extra == "dev"
Requires-Dist: statsmodels>=0.14; extra == "dev"
Dynamic: license-file

# databubble-scoring

Pure, offline scoring/replay logic for DataBubble model artifacts: `ModelCard`
(linear/OLS), `Scorecard` (classification), and `SegmentScorer`
(segmentation). No network calls, no DataBubble platform dependency —
dependencies are `numpy`, `pandas`, `scipy`, and `pydantic` only.

**Import name note:** the distribution is `databubble-scoring` (PyPI name,
hyphen), but Python module names can't contain hyphens — the package you
actually import is `databubble_scoring` (underscore):

```python
import databubble_scoring
from databubble_scoring.model_card import ModelCard, apply_recipe
from databubble_scoring.predict import predict_from_card
```

## Why this package exists

The DataBubble platform (`code/`) fits models and exports them as portable
JSON artifacts (a `ModelCard`, `Scorecard`, or `SegmentScorer`) that fully
describe how to replay the fit-time feature encoding and scoring math against
new rows — no re-fitting, no server round-trip required in principle. This
package is the single source of truth for that replay logic: both the
platform's own hosted `/predict`/`/score` routes and the SDK's offline/MLflow
artifact path import from here, so the two can never silently diverge.

## What's here

- `model_card.py` — `ModelCard`/`ModelCardBundle`, `FeatureRecipe` (the
  portable encoding-replay contract), `apply_recipe`, `predict`-adjacent
  construction helpers.
- `predict.py` — `predict_from_card`/`predict_from_bundle` (linear/OLS
  prediction with CI/PI bands).
- `classifier.py` — `FittedPipeline` and `score_observations`, the pure
  scoring core shared by classification and segmentation (fit-time logic —
  `fit_classifier` itself, which needs scikit-learn — stays in the platform).
- `scorecard.py` / `segment_scorer.py` — `Scorecard`/`SegmentScorer` artifact
  models plus `score_from_scorecard`/`score_from_segment_scorer`.
- `model_comparison.py` — `compare_by_ic`/`compare_nested`, card-only model
  comparison (AIC/BIC, nested F-test).
- `drift_monitoring.py` — `diagnose_feature_drift`, comparing a new batch
  against a card's fit-time `feature_snapshot`.
- `mlflow_pyfunc.py` (optional `[mlflow]` extra) — wraps any of the three
  artifact types as an `mlflow.pyfunc.PythonModel`, so a customer can load a
  DataBubble model into their own MLflow registry and score it locally, with
  zero DataBubble network call at inference.

## Install

```bash
pip install databubble-scoring
pip install "databubble-scoring[mlflow]"   # adds MLflow pyfunc support
```

Not yet published to PyPI — see the platform/SDK repos' own docs for the
local editable-install step during development.
