Skip to main content

Production-grade scorecard development toolkit

Project description

ProScore

PyPI version Python License: MIT

生产级评分卡开发工具包
端到端的确定性评分卡建模管线,为银行和金融机构的信用评分卡建模场景设计, 满足对可解释性、合规性和稳定性的要求。


目录


三种使用方式

ProScore 提供三种递进的使用方式,从零代码到完全自定义,按需选择。

方式 适合 门槛
A. 模块独立使用 需要自定义逻辑、部分环节手动干预 熟悉 Python
B. 链式 API 标准建模流程,一行到底 会写 Python
C. Excel 配置驱动 业务人员零代码,一套 Excel 跑到底 会填 Excel

A. 模块独立使用

每个模块可单独 import,适合在任意环节插入自定义逻辑。

from proscore.inspect import detect, quality
from proscore.selection import Filter
from proscore.binning import Binning
from proscore.transform import WOETransformer
# ... 按需组合

详见 使用指南 各模块手册。

B. 链式 API

标准建模流程,数据切分与模型边界严格分离(Train/Test/OOT)。

import proscore as ps

p = (
    ps.ProScore()
    .read(train=df_train, test=df_test, oot=df_oot, target="bad_flag")
    .detect()
    .prefilter()
    .bin(method="chi", n_bins=5)
    .refine(iv_range=(0.02, None))
    .transform()
    .select(method="stepwise")
    .fit(odds=20, pdo=20, base_score=600)
    .scorecard()
    .evaluate()  # 自动汇报 train / test / oot 三列指标
)

train 必传,testoot 可选。分箱/WOE 只在 train 上拟合;逐步回归用 test 监控过拟合;OOT 仅用于最终评估。

完整教程见 notebooks/ProScore完整建模流程.ipynb

C. Excel 配置驱动

拿模板填参数,一行命令跑通全流程。不需要写一行代码。

# 1. 获取空白配置模板(二选一)
cp examples/pipeline_template.xlsx ./my_project/   # 克隆仓库后可直接复制
# 或: proscore template ./my_project/

# 2. 打开 Excel,填 data_file、target、time_col 等参数

# 3. 运行
proscore run my_project/pipeline_template.xlsx

# 可选:导出等效 Python 脚本
proscore run my_project/pipeline_template.xlsx --output-script run.py

模板含 7 个 Sheet(Global / Data / Steps / Binning / Screening / Modeling / Variables),每个参数带中文说明、可选范围和默认值。留空 = 使用默认值。无 OOT 时最少只需填 data_filetargettime_col 3 个格子;有 OOT 时再补充时间切分参数。

详细参数说明见 pipeline-config.md


核心功能概览

模块 核心能力 业务价值
数据探查 IV/AUC/KS 三指标 + PSI 时序稳定性 + 相关性/VIF 快速筛选优质变量,识别分布漂移风险
分箱 4 种单调趋势 + 5 种分箱方法 + 两阶段趋势校验 确保 WOE 趋势符合业务逻辑,满足监管
逐步回归 双向选择 + 五重约束(p值/符号/VIF/相关/来源) 严谨的多重共线性控制与维度归属管理
模型监控 Score/Feature PSI + 规则引擎告警 + JSON 持久化 投产后持续验证,自动风险预警
报告生成 7 章自动 Markdown 报告(含图表) 银保监合规文档一键生成

设计原则

  • 确定性:相同输入 → 相同输出,不依赖随机优化器。
  • sklearn 风格:统一 fit() / transform() 接口。
  • 生产就绪:内置 unseen 处理、inf 容错、分箱序列化。
  • 轻量核心:仅 numpy/pandas/scikit-learn/statsmodels,XGBoost/LightGBM 为可选依赖。

安装

核心依赖仅需 numpy、pandas、scikit-learn、statsmodels,无重依赖:

pip install proscore

如需使用 XGBoost 或 LightGBM 作为变量质量评估的备选估计器(在 inspect.quality() 中启用 estimator="xgb"estimator="lgb"),安装对应的可选依赖组:

pip install proscore[inspect-ml]

为什么是可选?XGBoost 和 LightGBM 体积较大,且涉及平台相关的编译依赖。绝大多数场景下,默认的逻辑回归估计器已经足够可靠。仅在需要用树模型对变量进行非线性排序时才需安装。

后续 AI / LLM 相关功能同样会以可选依赖组方式发布(如 proscore[ai]),不强制安装,不拖累核心包体积。


依赖

  • Python >= 3.9
  • numpy >= 1.20
  • pandas >= 1.5
  • scikit-learn >= 1.2
  • statsmodels >= 0.13

可选依赖

依赖组 安装命令 用途
inspect-ml pip install proscore[inspect-ml] XGBoost / LightGBM 用于变量质量评估
excel pip install proscore[excel] openpyxl,用于 proscore runload_presets()

proscore run 命令由 [project.scripts] 注册,安装后即可使用。

License

MIT

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

proscore-0.1.1.tar.gz (103.0 kB view details)

Uploaded Source

Built Distribution

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

proscore-0.1.1-py3-none-any.whl (102.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: proscore-0.1.1.tar.gz
  • Upload date:
  • Size: 103.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for proscore-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9d150fdb20fd6d8dbfb4788253a3ec0685cfa62b351ecd11ccf4aa0462d6f6c3
MD5 52352f4d4416c4698ae2c2b1baa8f7cb
BLAKE2b-256 bdaa14ce876d50631e92a28bb639ce560e73d0d308fa84b7583d30e7c0fc1b17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: proscore-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 102.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for proscore-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b5ffe67a83f19a4b07ce32d61a6e159a12e3be363e38817c62cdb397fc8a5f4
MD5 00a32ddbf1f085261eeb0e4a8c3f0e0c
BLAKE2b-256 b6d12077407af2ddd4bfe9c5e0a91251500149aa908cc0b6e320b6367cae17ac

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