utilsds-models
A library of classes and functions used in DS Team modeling projects. It extends the utilsds package with components specific to selected models (data processing, NGR metrics, EVIP metrics, and a custom LightGBM objective).
Requires Python >= 3.12.
Installation
uv sync
source .venv/bin/activate
Or from PyPI (after publication):
pip install utilsds-models
Modules
data_processing
Scikit-learn-compatible classes and helper functions for combining test results.
ColumnCopyImputer: fills missing values by copying from other columns.NullImputerWithFlags: imputes nulls with optional flags (_isnull_flag) and strategiesmean,median,mode.MaxMultiplierImputer: imputes usingmax * multiplierfrom training data, with optional flags.SportsHybridEncoder: encodes sports as binary features for the top N disciplines plus aggregations for the rest.LabelEncoderTransformer: label encoding for categorical columns (e.g. for LightGBM).DerivedFeatureCreator: creates derived features (e.g. division by 7 or 30).combine_test_data: combines test features, target, predictions, and metadata into a single DataFrame.
custom_metrics
Evaluation metrics with time-based weights (days_since_ftd) and a custom LightGBM objective.
EvalMetric: cohort-level (aggregated bydays_since_ftd) and sample-level metrics with time-decay weighting:cohort_weighted_mae,cohort_weighted_mse,cohort_weighted_mapesample_weighted_mae,sample_weighted_mse,sample_weighted_mapecreate_lgb_metric: factory for LightGBM metrics with time weights
DaysWeightedObjective: custom LightGBM objective with time weights (modes:mae,mse,mape).
metrics
calculate_ngr_metrics: computes NGR error metrics (MAE, MAPE, ME, MPE) in both standard and business-optimal variants with weights based ondays_since_ftd. Optionally applies late-stage prediction correction over the customer lifecycle.
visualization
calculate_ngr_metrics: NGR evaluation function (equivalent to themetricsmodule).
evip_dynamic
Classification metrics with a false-positive (FP) budget constraint.
recall_with_fp_cap: recall with a penalty for exceeding the FP budget in binary classification.weighted_premium_recall_with_fp_cap: weighted recall for premium classes (1 and 2) with a penalty for exceeding the FPR budget among class 0 samples.
Dependencies
pandas>=2.2.2numpy>=1.26.0scikit-learn>=1.5.0matplotlib>=3.9.0
Publishing to PyPI
uv pip install build twine
uv run python -m build
twine upload --skip-existing dist/*
Before publishing, bump the version in pyproject.toml (section [project]).
Metadata
Release files for utilsds-models 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| utilsds_models-0.0.5.tar.gz | 15.3 kB | Without provenance | Details for utilsds_models-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| utilsds_models-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for utilsds_models-0.0.5-py3-none-any.whl |
Total release size: 32.1 kB
Release files / utilsds_models-0.0.5.tar.gz
| Download URL | utilsds_models-0.0.5.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4be86197bbcbf9b4b45e4b7d3b95f24dda0d3437d0ab1287963da53126804f3f
|
|
BLAKE2b-256 checksum How to use checksums |
9e36e609b1a281144abb07d1766968b71bcf034a418a5bb37bbcecf114e2e951
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|
Release files / utilsds_models-0.0.5-py3-none-any.whl
| Download URL | utilsds_models-0.0.5-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d53db09324b557ee3481076923133c340626dfce8cb6719d24f9b8bd648b95c0
|
|
BLAKE2b-256 checksum How to use checksums |
229e4772924ca8464e487ae3ba33f782d0eef45a417fe82b7c5ea401dfd38af2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|
Security for utilsds-models 0.0.5
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.