Skip to main content

评分卡模型实现函数模块 - 轻松解决逻辑回归建模

Project description

Yihuier

一会儿轻松解决信用评分卡建模

基于 Scorecard--Function 重构的面向对象版本。

特性

  • 面向对象设计 - 统一的 Yihuier 类管理数据和状态
  • 完整建模流程 - EDA → 数据处理 → 分箱 → 变量选择 → 模型评估 → 评分卡实现 → 监控
  • 模块化架构 - 9个独立模块,职责清晰
  • 类型提示 - 完整的类型注解,更好的IDE支持

快速开始

安装

# 使用 pip
pip install yihuier

# 或使用 uv
uv pip install yihuier

基础使用

import pandas as pd
from yihuier import Yihuier

# 加载数据
data = pd.read_csv('data.csv')
yh = Yihuier(data, target='dlq_flag')

# 数据预处理
data_clean = yh.dp_module.delete_missing_var(threshold=0.15)

# 变量分箱
bin_df, iv_value = yh.binning_module.binning_num(
    col_list=['v1', 'v2', 'v3'],
    max_bin=5,
    method='ChiMerge'
)

# WOE转换
woe_df = yh.binning_module.woe_df_concat()
data_woe = yh.binning_module.woe_transform()

# 变量选择
xg_imp, xg_rank, xg_cols = yh.var_select_module.select_xgboost(
    col_list=data_woe.drop(['dlq_flag'], axis=1).columns.tolist(),
    imp_num=10
)

# 模型训练
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(data_woe[xg_cols], data_woe['dlq_flag'])

# 模型评估
y_pred = model.predict_proba(x_test)[:, 1]
yh.me_module.plot_roc(y_test, y_pred)
yh.me_module.plot_model_ks(y_test, y_pred)

模块概览

模块 功能 文档
EDAModule 探索性数据分析 📖 EDA 模块
DataProcessingModule 数据预处理 📖 数据预处理
BinningModule 变量分箱 📖 分箱模块
VarSelectModule 变量选择 📖 变量选择
ModelEvaluationModule 模型评估 📖 模型评估
ScorecardImplementModule 评分卡实现 📖 评分卡实现
ScorecardMonitorModule 评分卡监控 📖 评分卡监控
ClusterModule 聚类分析 📖 聚类模块
PipelineModule 流水线 📖 流水线模块

📚 完整文档

开发

# 克隆项目
git clone https://github.com/ency/yihuier.git
cd yihuier

# 安装开发依赖
uv pip install -e ".[dev]"

# 运行测试
pytest tests/ -v

# 代码格式化
ruff format yihuier/
ruff check yihuier/

许可证

MIT License

致谢

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

yihuier-0.2.2.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

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

yihuier-0.2.2-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file yihuier-0.2.2.tar.gz.

File metadata

  • Download URL: yihuier-0.2.2.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yihuier-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3b32c98ba78ee3c23b262560ac64accaa9efa7b3f42ffa795bec3662d9ac914d
MD5 71f6f9e04da62a30904743ec408fa14c
BLAKE2b-256 8aa24e541fc97366eed8fe1932cc301468d428d3799371636493815e82f118d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for yihuier-0.2.2.tar.gz:

Publisher: publish.yml on encyc/yihuier

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yihuier-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: yihuier-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yihuier-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 761806dce8044ac4cfd49b87704cd9ffd66e25664d3844b5319d50a930d3a551
MD5 0a500feba798c4594985bba7b144d6ef
BLAKE2b-256 3b68cd5b528d1e5433f301c5d5d271600d9227544b7e2be8846ab7bb8ee6a1dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for yihuier-0.2.2-py3-none-any.whl:

Publisher: publish.yml on encyc/yihuier

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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