跳转至

MARS

MODELING ANALYSIS RISK SCORE 面向信用风控分析与建模的 Polars-first 高性能工具库 Profile to Bin and Evaluate to Analyze to Select to Modeling to Pipeline to Monitor to Report

MARS 是面向信用风控宽表分析、分箱评估、特征筛选、建模和监控的 Polars-first Python 工具库。它接受 Pandas 或 Polars 数据,并返回可继续读取和加工的结构化 report 对象。

pip install mars-risk==0.0.28
import polars as pl

from mars.analysis import profile_risk

df = pl.DataFrame(
    {
        "apply_dt": [
            "2026-01-03",
            "2026-01-10",
            "2026-01-17",
            "2026-01-24",
            "2026-02-03",
            "2026-02-10",
            "2026-02-17",
            "2026-02-24",
            "2026-03-03",
            "2026-03-10",
            "2026-03-17",
            "2026-03-24",
        ],
        "month": ["2026-01"] * 4 + ["2026-02"] * 4 + ["2026-03"] * 4,
        "income": [
            3200,
            3600,
            -999,
            None,
            3300,
            4200,
            -999,
            5800,
            3400,
            4300,
            None,
            6100,
        ],
        "utilization": [
            0.12,
            0.18,
            0.52,
            0.61,
            0.14,
            0.29,
            0.54,
            0.58,
            0.16,
            0.31,
            0.56,
            0.63,
        ],
        "segment": [
            "new",
            "repeat",
            "vip",
            "vip",
            "new",
            "repeat",
            "vip",
            "vip",
            "new",
            "repeat",
            "vip",
            "vip",
        ],
        "target": [0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1],
    }
)

risk_profile = profile_risk(
    df,
    target="target",
    features=["income", "utilization", "segment"],
    group_col="month",
    time_col="apply_dt",
    binning_type="native",
    method="quantile",
    n_bins=4,
    missing_values=[-999],
    special_values=[-999],
    psi_include_missing=False,
    psi_include_special=False,
)

report = risk_profile.report
summary = report.summary_table
binner = risk_profile.binner

risk_profile.report 提供汇总、分箱明细和趋势表;risk_profile.binner 保存本次拟合的分箱规则。 完整说明见10 分钟 Quickstart

从任务开始

入口怎么选

目标 推荐入口 主要输出
数据质量与分布检查 MarsDataProfiler.generate_profile() MarsProfileReport
一次性风险评估 profile_risk() MarsRiskProfile
固定分箱规则评估 MarsBinEvaluator.evaluate() MarsRiskProfile
统计、线性或重要性筛选 MarsStatsSelector 特征列表与筛选报告
周期分布与表现监控 MarsMonitor.monitor() MarsMonitoringReport
建模与实验复现 MarsModelingSession / MarsModelingPipeline 建模结果与 artifact

稳定性

Analysis、Feature、Reporting 是当前 Stable 模块。Rule、Monitoring、Modeling、Pipeline、Scoring 为 Experimental:受控生产流程应固定精确版本,并为关键结果和导出产物增加契约回归。 完整规则见稳定性与兼容性

版本

本站面向 MARS 0.0.28。该版本正式发布前,安装命令仅用于文档预览验收,不能作为已发布 PyPI 包的可用性证明。