Modeling_Tool.Pipeline¶
One-click pipelines. Each pipeline is a class that takes a config dataclass, runs with Pipeline(config).run(data)
(ScoreConsistencyUATPipeline can also read SQL files, and MockSamplePipeline needs no data), and returns a result
dataclass. This page is the generated reference. The Top-Level Pipelines guide explains what each
pipeline does and how to configure it.
All names below are also importable from Modeling_Tool, for example
from Modeling_Tool import CreditModelPipeline, CreditModelPipelineConfig.
Credit Model Pipeline: credit_model¶
credit_model
¶
CreditModelPipelineConfig
dataclass
¶
Configuration of :class:CreditModelPipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str
|
Root of all outputs: the CSV files, the |
"output"
|
clean_output_dir
|
bool
|
After a successful run, remove the files that the previous manifest of this pipeline lists and this run did not
write again (the outputs of stages that no longer run), and the directories they leave empty. Only files of the
manifest are removed: files written by hand, by another pipeline, by a version without the manifest, or under
|
False
|
target_col
|
str
|
Binary target column (1 = bad). It must be a column of the input data. |
"badflag"
|
feature_cols
|
list of str or None
|
Raw model input features. |
None
|
split_col
|
str or None
|
Column with the sample labels |
None
|
sample_col
|
str
|
Legacy sample label column with the same labels, used when |
"sample_ind"
|
oot_col
|
str or None
|
OOT flag column, used only when the sample labels do not define INS and OOS: rows with a non-zero flag (missing
counts as 0) become OOT and the others are split randomly into INS and OOS (see |
"oot_flag"
|
weight_col
|
str or None
|
Sample-weight column of the input data (finite, non-negative, with a positive sum; |
None
|
random_state
|
int
|
Seed of the random INS/OOS split (unless |
42
|
write_outputs
|
bool
|
Whether to write the CSV files and the explanation files into |
True
|
write_excel
|
bool
|
Whether to write |
True
|
plot_outputs
|
bool
|
Whether to draw the charts: the IV and WOE analysis plots of the screening ( |
True
|
save_models
|
bool
|
Whether to save every trained model as |
False
|
model_output_dir
|
str or None
|
Directory of the saved models. |
None
|
model_include_metadata
|
bool
|
|
True
|
save_woe_artifacts
|
bool
|
With |
True
|
split_config
|
dict
|
Settings of the random INS/OOS split, which runs only when the sample labels do not define INS and OOS:
|
{'test_size': 0.3, 'stratify': True}
|
feature_selection
|
dict
|
Settings of the PSI, IV and correlation screening, keyed like the fields of |
{'psi_enabled': True, 'psi_threshold': 0.2, 'psi_compare_splits': ['oos'], 'iv_enabled': True, 'iv_threshold': 0.02, 'iv_upper_threshold': 2.0, 'corr_enabled': True, 'corr_threshold': 0.75, 'corr_max_iterations': 10}
|
woe_engine
|
str
|
WOE binning engine: |
"equal_freq"
|
woe_fit_query
|
str or None
|
pandas |
None
|
extra_eval_datasets
|
dict of str to pandas.DataFrame or None
|
Evaluation-only frames |
None
|
woe_params
|
dict
|
Parameters of the |
{'nbins': 10, 'equal_freq': True, 'min_bin_prop': 0.05, 'sv_min_bin_size': 0.0, 'sv_small_policy': 'keep', 'sv_woe_smoothing': 'none', 'sv_smoothing_alpha': 0.0}
|
monotone_woe_params
|
dict
|
Parameters of the |
{'n_init_bins': 20, 'min_bin_size': 0.03, 'min_n_bins': 2, 'sv_min_bin_size': 0.0, 'sv_small_policy': 'keep', 'sv_woe_smoothing': 'none', 'sv_smoothing_alpha': 0.0, 'unseen_special_policy': 'neutral'}
|
train_models
|
list of str
|
Models to train, any of |
['lr', 'lgb', 'xgb', 'cat']
|
model_params
|
dict of str to dict
|
Per-model parameter overrides |
{}
|
gbm_feature_source
|
str or dict of str to str
|
Input features of the GBM models: |
"woe"
|
lr_search_enabled
|
bool
|
Whether to run a hyper-parameter grid search for the LR model ( |
False
|
lr_search_param_grid
|
dict of str to list
|
Parameter grid of the LR search, searched as a Cartesian product. |
{'C': [0.01, 0.1, 1.0, 10.0]}
|
lr_search_params
|
dict
|
Overrides of the LR search settings. The allowed keys are |
{}
|
use_lr_search_params
|
bool
|
Whether the best parameters of the LR search are merged over |
True
|
lr_elimination_mode
|
str or None
|
Backward elimination of the final LR model: |
None
|
lr_elimination_params
|
dict
|
Settings of the p-value elimination: |
{}
|
warm_start_enabled
|
bool
|
Whether to start the GBM models from a prior score (LightGBM |
False
|
warm_start_score_col
|
str or None
|
Column of the input data that holds the prior score. It is required when |
None
|
warm_start_score_type
|
('probability', 'log_odds')
|
|
"probability"
|
warm_start_models
|
list of str
|
GBM models that use the warm start, compared case-insensitively. |
['lgb', 'xgb']
|
warm_start_on_unsupported
|
('skip', 'raise')
|
What to do when |
"skip"
|
warm_start_apply_to_optuna
|
bool
|
Whether to pass the prior score as |
False
|
warm_start_score_scope
|
('full', 'train')
|
Where the prior score is seen. |
"full"
|
backward_enabled
|
bool
|
Whether to run backward variable elimination on the WOE features before the models are trained. |
True
|
backward_model
|
str
|
Proxy model of the backward elimination: |
"lgb"
|
backward_params
|
dict
|
|
{}
|
use_backward_features
|
bool
|
|
True
|
candidate_mode
|
bool
|
|
False
|
synthesize_missing_oot
|
bool or None
|
When the data has no real OOT rows: |
False
|
evaluation_splits
|
list of str or None
|
Splits that the performance evaluation, the charts and the Excel report use. |
None
|
forbidden_splits
|
list of str
|
Splits that no stage may consume, such as |
[]
|
search_eval_splits
|
list of str or None
|
Splits that the LR search and the Optuna search evaluate on. |
None
|
search_objective_when_no_oot
|
str
|
Objective of the LR and Optuna searches when |
"max_primary"
|
backward_validation_split
|
str
|
Split used as the validation data of the backward elimination: |
"oos"
|
backward_report_splits
|
list of str or None
|
Splits on which the backward elimination reports performance after each round. |
None
|
optuna_models
|
list of str
|
Models to tune with Optuna; |
['lgb', 'xgb', 'cat']
|
optuna_n_trials
|
int
|
Number of Optuna trials per model. |
5
|
optuna_params
|
dict
|
Optuna settings: |
{}
|
explain_models
|
list of str
|
Trained models explained with SHAP: |
['lr', 'lgb', 'cat']
|
explain_params
|
dict
|
Explanation settings: |
{'sample_n': 500, 'background_n': 200}
|
owen_enabled
|
bool
|
Whether to compute Owen values (Shapley values over groups of related features) for every trained model except
|
True
|
business_prior_groups
|
dict of str to list of str or None
|
Business groups |
None
|
perf_pct_bins
|
int
|
Number of percentile bins of the performance evaluation. |
10
|
perf_min_bin_prop
|
float
|
Minimum share of a bin in the Gains tables of the performance evaluation ( |
0.03
|
eval_target_cols
|
list of str or None
|
Extra label columns evaluated against the same model scores in addition to |
None
|
all_missing_score_value
|
float or None
|
Score given in the evaluation to rows whose raw model features are all missing (for example -1), the rule of the
scoring API; |
None
|
special_score_values
|
list of float or None
|
Sentinel scores (for example |
None
|
gains_ascending
|
bool or None
|
Score direction of the evaluation summary, the gains tables and the figures: |
True
|
eval_weight_col
|
str or None
|
Weight column of the evaluation, of the validation weights of the backward elimination and of the LR and Optuna
searches. |
"inherit"
|
screening_artifact
|
FeatureScreeningArtifact or None
|
Output of |
None
|
feature_validation_result
|
FeatureValidationPipelineResult or None
|
Convenience field: the result of |
None
|
feature_selection_mode
|
('run', 'from_artifact', 'skip')
|
|
"run"
|
reuse_screening_woe
|
bool
|
With an artifact, reuse the WOE engine it carries for the target instead of fitting again, provided it covers
at least one selected feature (features it did not fit are left out of every model, with a |
True
|
screen_iv_convention
|
('guarded', 'raw')
|
How the screening IV on the bins of a WOE engine (a |
"guarded"
|
Source code in Modeling_Tool/Pipeline/credit_model.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
CreditModelPipelineResult
dataclass
¶
Result returned by :meth:CreditModelPipeline.run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
splits
|
dict of str to pandas.DataFrame
|
The raw (not WOE-transformed) working splits: |
required |
feature_selection_summary
|
dict
|
Outcome of the feature selection: |
required |
woe_artifacts
|
dict
|
The WOE step: |
required |
models
|
dict of str to tuple
|
|
required |
selected_features
|
list of str
|
The WOE features chosen before the models were trained (after the backward elimination when
|
required |
backward_summary
|
DataFrame or None
|
Summary of the backward elimination; a one-row frame with the columns |
None
|
optuna_results
|
dict of str to pandas.DataFrame
|
Optuna search table per model; a single-column |
{}
|
perf_results
|
dict of str to pandas.DataFrame
|
Performance summary table per model ( |
{}
|
explain_outputs
|
dict
|
Explanation outputs per model: |
{}
|
explain_paths
|
dict of str to dict of str to str
|
Index of the files written under |
{}
|
report_path
|
str or None
|
Path of the Excel report. |
None
|
lr_search_results
|
DataFrame or None
|
Table of the LR grid search. |
None
|
warm_start_summary
|
DataFrame or None
|
One row per requested warm-start model ( |
None
|
model_feature_sources
|
dict of str to str
|
|
{}
|
model_feature_sets
|
dict of str to list of str
|
The features each model was given for training, evaluation and explanation; the LR p-value elimination is not
reflected here (see |
{}
|
selected_raw_features
|
list of str
|
The final feature set under the raw column names (what a raw GBM uses). |
[]
|
selected_woe_features
|
list of str
|
The final feature set under the WOE column names (what LR and WOE-based GBMs use). |
[]
|
model_paths
|
dict of str to str
|
|
{}
|
artifact_paths
|
dict of str to str
|
Paths of the saved |
{}
|
split_governance
|
dict
|
The effective OOT-governance settings of the run: |
{}
|
Source code in Modeling_Tool/Pipeline/credit_model.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | |
CreditModelPipeline
¶
Reusable credit modeling workflow: split, feature selection, WOE, models, evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
CreditModelPipelineConfig or None
|
Pipeline settings. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
config |
CreditModelPipelineConfig
|
The settings in use. |
predict_positive_nan_stats |
dict of str to dict of str to int
|
Filled by |
Notes
Several stages catch their own failures instead of stopping the run, and record the error in the result: the
feature selection (feature_selection_summary["error"], every feature is kept except the leak-gate drops found
before the failure), the backward elimination
(backward_summary with the columns step and error), each Optuna search (a table with the column
error) and the explanations (an error entry per model).
Source code in Modeling_Tool/Pipeline/credit_model.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 | |
run
¶
run(data: DataFrame) -> CreditModelPipelineResult
Run the whole workflow on one dataset and return everything it produced.
The steps are the INS/OOS/OOT split, the feature screening, the WOE fit and transform, the backward
elimination, the LR search, the model training, the Optuna search, the evaluation, the explanations, the model
saving, the CSV output and the Excel report; the settings of CreditModelPipelineConfig switch them on or off.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Modeling data with |
required |
Returns:
| Type | Description |
|---|---|
CreditModelPipelineResult
|
The splits, the feature selection summary, the WOE artifacts, the trained models, the selected features and the optional search, performance, explanation and path outputs. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a required column is missing from |
ValueError
|
If the data or the settings are invalid: weights, sample labels, |
TypeError
|
If |
NotImplementedError
|
If |
Notes
The failures that the feature selection, the backward elimination, each Optuna search and the explanations catch are not raised; they are recorded in the result (see the class notes).
Source code in Modeling_Tool/Pipeline/credit_model.py
Feature Validation Pipeline: feature_validation¶
feature_validation
¶
FeatureValidationPipelineConfig
dataclass
¶
Configuration of :class:FeatureValidationPipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str
|
Output directory. CSV tables and the Excel report are written directly into it, WOE plots to
|
'output/feature_validation'
|
clean_output_dir
|
bool
|
After a successful run, remove the files that the previous manifest of this pipeline lists and this run did not write again (tables of stages that no longer run, batch folders of a former batch layout), and the directories they leave empty. Only files of the manifest are removed: files written by hand, by another pipeline or by a version without the manifest stay. |
False
|
id_col
|
str
|
Unique row identifier column. It must exist in the data ( |
'flow_id'
|
apply_time_col
|
str
|
Application time column; it must exist in the data. When |
'apply_time'
|
target_cols
|
list of str or None
|
Target columns (1 = bad). Names that are not columns of the data are ignored silently. WOE, IV/KS, correlation detail and selection need at least one target; the first target drives the stratified INS/OOS split and the selection. |
None
|
new_feature_cols
|
list of str or None
|
Features to validate. |
None
|
incumbent_feature_cols
|
list of str or None
|
Existing features to compare with the new ones in the correlation analysis. Names that are also new features are ignored. They must exist in the data. |
None
|
input_type
|
('auto', 'dataframe', 'csv')
|
How |
'auto'
|
csv_read_kwargs
|
dict
|
Extra keyword arguments for |
{}
|
enable_batch
|
bool
|
Process a CSV in batches of feature columns to limit memory. It requires CSV input, and |
False
|
feature_batch_size
|
int or None
|
Number of new features per batch; must be positive. |
None
|
feature_batches
|
list of list of str or None
|
Explicit feature batches; they take precedence over |
None
|
batch_base_cols
|
list of str or None
|
Extra columns read with every batch. The id, application time, split, sample, OOT, target, time, population, categorical, WOE-plot-group and incumbent columns that exist in the CSV are always read. |
None
|
batch_output_subdir
|
str
|
Sub-directory of |
'feature_batches'
|
batch_keep_intermediate
|
bool
|
Whether each batch writes its own CSV tables and plots (subject to |
True
|
batch_corr_mode
|
('within_batch', 'block_pairwise', 'off')
|
Correlation report in batch mode. |
'within_batch'
|
batch_corr_pair_chunk_size
|
int or None
|
With |
None
|
split_col
|
str or None
|
Column with sample labels (case and surrounding spaces ignored). It must contain non-empty |
None
|
sample_col
|
str
|
Legacy label column, used when |
'sample_ind'
|
oot_col
|
str or None
|
Numeric OOT flag column of the fallback split: rows with 0 or a missing value are INS/OOS candidates and non-zero
rows are OOT. A non-numeric flag raises |
'oot_flag'
|
split_config
|
dict
|
Settings of the random INS/OOS split: |
{'test_size': 0.3, 'stratify': True}
|
random_state
|
int
|
Seed of the random INS/OOS split unless |
42
|
time_dims
|
list of str
|
Time columns for the grouped analyses (distribution, PSI, IV/KS). |
['apply_month']
|
population_dims
|
list of str
|
Population columns (for example channel) for the grouped analyses; columns absent from the data are skipped. |
[]
|
group_specs
|
dict or list or None
|
Custom groups for the distribution tables only: |
None
|
min_group_size
|
int
|
Minimum row count. A target needs at least |
100
|
distribution_enabled
|
bool
|
Whether to build |
True
|
distribution_params
|
dict
|
Keys: |
{'q': [0.05, 0.15, 0.25, 0.5, 0.75, 0.95, 0.99]}
|
woe_enabled
|
bool
|
Whether to fit WOE binning per target on the INS rows with an observed target. It needs a target. Without it PSI, IV/KS and correlation use their own binning. |
True
|
woe_fit_query
|
str or None
|
pandas |
None
|
woe_engine
|
str
|
|
'monotone'
|
woe_params
|
dict
|
Used with |
{'nbins': 10, 'equal_freq': True, 'min_bin_prop': 0.05, 'sv_min_bin_size': 0.0, 'sv_small_policy': 'keep', 'sv_woe_smoothing': 'none', 'sv_smoothing_alpha': 0.0}
|
monotone_woe_params
|
dict
|
Used with |
{'n_init_bins': 20, 'min_bin_size': 0.03, 'min_n_bins': 2, 'sv_min_bin_size': 0.0, 'sv_small_policy': 'keep', 'sv_woe_smoothing': 'none', 'sv_smoothing_alpha': 0.0, 'unseen_special_policy': 'neutral'}
|
categorical_features
|
list of str or None
|
Features binned as categorical by the monotone engine ( |
None
|
monotone_refine_cate_enabled
|
bool
|
Whether to call |
False
|
monotone_refine_cate_params
|
dict
|
Keyword arguments of |
{}
|
monotone_refine_dtree_enabled
|
bool
|
Whether to call |
False
|
monotone_refine_dtree_params
|
dict
|
Keyword arguments of |
{}
|
monotone_refine_chi2_enabled
|
bool
|
Whether to call |
False
|
monotone_refine_chi2_params
|
dict
|
Keyword arguments of |
{}
|
woe_plot_groups
|
list of str
|
Group columns for extra WOE plots by group ( |
[]
|
psi_enabled
|
bool
|
Whether to compute |
True
|
psi_reference_dataset
|
str
|
Reference sample of the PSI: |
'ins'
|
psi_reference_data
|
DataFrame or None
|
Reference data for |
None
|
psi_group_dims
|
list of str
|
Grouping of the PSI: |
['sample', 'time', 'population']
|
psi_use_woe_bins
|
bool
|
Whether to bin with the WOE engine of each target when available. Otherwise |
True
|
psi_params
|
dict
|
Keyword arguments of |
{'buckets': 10, 'equal_freq': True, 'min_bin_prop': 0.05}
|
ivks_enabled
|
bool
|
Whether to compute |
True
|
ivks_group_dims
|
list of str
|
Groupings of the IV/KS report: |
['global', 'time', 'population']
|
ivks_use_woe_bins
|
bool
|
Whether to compute IV/KS on the bins of the WOE engine of each target when available. |
True
|
ivks_params
|
dict
|
|
{'iv_cut': 0.0}
|
corr_enabled
|
bool
|
Whether to compute |
True
|
corr_include_incumbent
|
bool
|
Whether incumbent features are included in the correlation analysis (and, with |
True
|
corr_use_woe_bins
|
bool
|
Whether |
True
|
corr_params
|
dict
|
|
{'corr_cutpoint': 0.75, 'method': 'pearson', 'max_iterations': 10, 'base_metric': 'iv'}
|
missing_rate_threshold
|
float or None
|
Maximum missing rate of a feature on INS (NaN or the |
None
|
selection_enabled
|
bool
|
Whether to run the feature screening (missing rate, PSI, IV and correlation stages and optional gates) on the
first target. It fills |
False
|
selection_params
|
dict
|
Screening settings read by the pipeline; other keys are ignored. Thresholds: |
{}
|
selection_group_dims
|
list of str or None
|
Columns of the group-stability gates ( |
None
|
weight_col
|
str or None
|
Sample-weight column of the weighted selection and its IV/direction evidence; it must exist in the data. The WOE bins are still fitted without weights. |
None
|
synthesize_missing_oot
|
bool or None
|
When no OOT rows exist, True copies the OOS rows in as a stand-in OOT (with a |
False
|
woe_fit_scope
|
('all', 'post_missing_gate')
|
|
'all'
|
write_outputs
|
bool
|
Whether to write the result tables as CSV files in |
True
|
write_excel
|
bool
|
Whether to write |
True
|
plot_outputs
|
bool
|
Whether to write the WOE plots to |
True
|
screen_iv_convention
|
('guarded', 'raw')
|
How the IV on the WOE bins treats a class-pure bin (no bad or no good row), whose WOE comes from the |
"guarded"
|
Source code in Modeling_Tool/Pipeline/feature_validation.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
FeatureValidationPipelineResult
dataclass
¶
Result returned by :meth:FeatureValidationPipeline.run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
splits
|
dict of str to pandas.DataFrame
|
Sample splits: |
required |
distribution_summary
|
dict of str to pandas.DataFrame
|
Distribution tables keyed |
required |
woe_artifacts
|
dict
|
WOE results: |
required |
psi_summary
|
DataFrame
|
PSI of each feature against the reference sample by group, with the columns |
required |
psi_details
|
dict
|
Detailed PSI tables keyed |
required |
ivks_summary
|
DataFrame
|
IV, KS and lift of each feature per target and group ( |
required |
corr_matrix
|
DataFrame
|
Correlation matrix of the numeric features (and incumbents when included); empty with fewer than two features or when correlation is disabled. |
required |
high_corr_pairs
|
DataFrame
|
Feature pairs whose absolute correlation exceeds |
required |
correlated_detail
|
DataFrame
|
Per correlated pair and target the metrics of both features ( |
required |
validation_summary
|
DataFrame
|
Two columns |
required |
output_paths
|
dict of str to str
|
Absolute paths of the files written: one CSV per table name plus |
{}
|
report_path
|
str or None
|
Absolute path of the Excel report; None when |
None
|
batch_metadata
|
DataFrame or None
|
CSV batch mode only: one row per batch ( |
None
|
batch_results
|
dict
|
CSV batch mode only: |
{}
|
selected_features
|
list of str
|
Features kept by the selection stage; empty when |
[]
|
selection_summary
|
dict
|
Selection audit: |
{}
|
screening_artifact
|
FeatureScreeningArtifact or None
|
Artifact for |
None
|
config_snapshot
|
dict
|
Effective settings of the run (targets, features, selection, WOE and batch-mode flags). |
{}
|
ivks_sv_pure_bins
|
DataFrame
|
The class-pure special-value bins found by the global rows of |
empty frame
|
Source code in Modeling_Tool/Pipeline/feature_validation.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
FeatureValidationPipeline
¶
Feature validation workflow for new wide-table feature feeds.
The pipeline splits the data into INS/OOS/OOT, then builds distribution tables, fits WOE bins per target and computes PSI, IV/KS and correlation reports (optionally feature selection). It can read a CSV file directly and process very wide files in batches of feature columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FeatureValidationPipelineConfig or None
|
Pipeline configuration. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
config |
FeatureValidationPipelineConfig
|
The configuration in use. |
Source code in Modeling_Tool/Pipeline/feature_validation.py
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 | |
run
¶
run(data: DataFrame | str | Path) -> FeatureValidationPipelineResult
Validate the new features in data and write the configured reports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame or str or Path
|
The feature table, or the path of a CSV file (see |
required |
Returns:
| Type | Description |
|---|---|
FeatureValidationPipelineResult
|
Splits, distribution, WOE, PSI, IV/KS, correlation and selection results, and the paths of the files written. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a required column is missing from the data. |
ValueError
|
If a configuration value is invalid ( |
TypeError
|
If |
FileNotFoundError
|
If a CSV path does not exist. |
Notes
In CSV batch mode a failing batch is recorded in batch_metadata (status='error') and the run continues
with the remaining batches.
Source code in Modeling_Tool/Pipeline/feature_validation.py
Reject Inference Pipeline: reject_inference¶
reject_inference
¶
RejectInferencePipelineConfig
dataclass
¶
Configuration of :class:RejectInferencePipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str
|
Root output directory: |
"output/reject_inference"
|
approved_col
|
str
|
Approval flag column: 1 marks approved rows and 0 rejected rows. Rows with any other value (including missing) belong to neither group. |
"approved"
|
target_col
|
str
|
Performance label (1 = bad). The labels of rejected rows are inferred, so any existing values are overwritten in
the RI datasets. Approved rows whose target is missing (not yet performed) stay in the RI datasets but are left
out of the pre-score, of the reference statistics, of model training and of the validation and OOT samples, and
so are rejected rows that get no inferred label ( |
"badflag"
|
score_col
|
str
|
Pre-score column holding the probability of bad (see |
"prescore_prob"
|
feature_cols
|
list of str or None
|
Feature columns of the pre-score and RI models. |
None
|
split_col
|
str or None
|
Column with |
None
|
random_state
|
int
|
Seed for the pre-score split, the OOT and validation sampling, the reference sampling, the random labels of the inference methods and the models (unless a model param sets its own seed). |
42
|
write_outputs
|
bool
|
Whether to write CSV files and plots: |
True
|
write_excel
|
bool
|
Whether to write |
True
|
train_prescore
|
bool
|
True trains a pre-score model on approved rows with an observed target and scores all rows into |
True
|
prescore_model_type
|
str
|
Pre-score model: |
"lgb"
|
prescore_params
|
dict
|
Model parameters that override the built-in defaults of |
{}
|
prescore_test_size
|
float
|
Share of the approved rows held out as the (stratified) validation set when the pre-score is trained. |
0.3
|
ri_methods
|
list of str
|
Reject-inference methods to run; the aliases |
['simple_augment', 'hard_cutoff', 'fuzzy_augment', 'parceling']
|
ri_method_params
|
dict of str to dict
|
Per-method parameters keyed by the full method name: |
{}
|
ri_score_direction
|
('high_bad', 'high_good')
|
Meaning of |
"high_bad"
|
train_ri_models
|
bool
|
Whether to train a model on every RI dataset (and the benchmark) and compare their train, validation and OOT
performance in |
True
|
ri_model_type
|
str
|
Model type of the RI models; same options as |
"lgb"
|
ri_model_params
|
dict
|
Model parameters that override the built-in defaults of |
{}
|
lr_nan_handling
|
('fillna_median', 'fillna_mean', 'fillna_0', 'raise')
|
NaN/Inf handling for logistic-regression models only (pre-score and RI models). The fill modes impute with values
learned on the training frame, re-applied at scoring time, with a |
"fillna_median"
|
include_no_ri_benchmark
|
bool
|
Whether to also train an approved-only model named |
True
|
ri_validation_frac
|
float
|
Share of the approved training pool with an observed target sampled (stratified by target) as validation data
unless approved OOS rows with an observed target are available. Must lie in (0, 1), and
|
0.2
|
save_models
|
bool
|
Whether to pickle the models with |
False
|
model_output_dir
|
str or None
|
Folder for the model files. |
None
|
model_include_metadata
|
bool
|
Whether the saved models carry the SMF metadata envelope (passed as |
True
|
write_ri_datasets
|
bool
|
Whether to write each RI dataset as |
True
|
ri_dataset_output_cols
|
list of str or None
|
Columns to keep in the RI dataset CSVs (missing names trigger a |
None
|
ri_dataset_warn_mb
|
float
|
A |
1024.0
|
oot_data
|
DataFrame or None
|
External out-of-time sample used for evaluation instead of a random hold-out. It needs |
None
|
oot_frac
|
float
|
Share of the approved rows with an observed target (at least one row) randomly held out as OOT when neither
|
0.2
|
perf_pct_bins
|
int
|
Number of percentile bins of |
10
|
min_bin_prop
|
float
|
Minimum share of samples per bin in |
0.03
|
ri_approved_data
|
DataFrame or None
|
External approved sample used only as the reference that fits the inference rules; the approved rows of the main
data are still the approved part of the output. It needs |
None
|
ri_approved_query
|
str or None
|
pandas |
None
|
ri_approved_func
|
callable or None
|
Function |
None
|
ri_approved_frac
|
float or None
|
Fraction in (0, 1] of the reference sample drawn at random. It cannot be combined with |
None
|
ri_approved_n
|
int or None
|
Number of rows drawn at random from the reference sample (must be positive and not exceed its size). It cannot be
combined with |
None
|
ri_approved_scope
|
('reference_only', 'output_subset')
|
|
"reference_only"
|
Source code in Modeling_Tool/Pipeline/reject_inference.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
RejectInferencePipelineResult
dataclass
¶
Result returned by :meth:RejectInferencePipeline.run.
The frames may contain the helper columns _smf_ri_row_id (and _smf_ri_split with split_col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
approved_data
|
DataFrame
|
Approved rows used as the approved part of the RI datasets, with the pre-score: all approved rows, or only the
reference rows with |
required |
rejected_data
|
DataFrame
|
Rejected rows ( |
required |
ri_datasets
|
dict of str to pandas.DataFrame
|
|
required |
ri_summary
|
DataFrame
|
One row per method: |
required |
ri_model_perf
|
DataFrame or None
|
One row per trained model (each RI method and |
None
|
best_method
|
str or None
|
Method with the highest OOT AUC (the first row of |
None
|
prescore_model
|
object or None
|
The fitted pre-score model. None when the pre-score was not trained. |
None
|
ri_models
|
dict
|
|
{}
|
report_path
|
str or None
|
Path of the Excel report; None when |
None
|
approved_full_data
|
DataFrame or None
|
All approved rows of the input (with pre-score), before any |
None
|
ri_approved_reference_data
|
DataFrame or None
|
The approved reference sample that was used to fit the inference rules. |
None
|
ri_approved_summary
|
DataFrame or None
|
Two columns |
None
|
model_paths
|
dict of str to str
|
|
{}
|
oot_summary
|
DataFrame or None
|
Two columns |
None
|
Source code in Modeling_Tool/Pipeline/reject_inference.py
RejectInferencePipeline
¶
Reusable reject-inference workflow for approved/rejected application data.
The pipeline (optionally) trains a pre-score model on the approved rows, infers labels for the rejected rows with each configured method, optionally trains a model per augmented dataset and ranks the methods by OOT AUC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
RejectInferencePipelineConfig or None
|
Pipeline configuration. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
config |
RejectInferencePipelineConfig
|
The configuration in use. |
predict_positive_nan_stats |
dict
|
|
Source code in Modeling_Tool/Pipeline/reject_inference.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 | |
run
¶
run(data: DataFrame) -> RejectInferencePipelineResult
Run the reject-inference workflow on the approved and rejected applications in data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Application data with all approved ( |
required |
Returns:
| Type | Description |
|---|---|
RejectInferencePipelineResult
|
Approved and rejected data, the RI datasets and summary, the model comparison, the best method and the report and model paths. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a required column is missing from |
ValueError
|
If the configuration is inconsistent (unknown model type, method or direction,
|
Notes
Warnings are issued when train_prescore=True overwrites an existing score_col (of data or of
ri_approved_data), when rows with a missing target are dropped from an external OOT or left out of model
training, and when non-finite values are imputed or predicted. With save_models=True the models are pickled
even if write_outputs is False.
Source code in Modeling_Tool/Pipeline/reject_inference.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | |
Score Comparison Pipeline: score_comparison¶
score_comparison
¶
ScoreComparisonPipelineConfig
dataclass
¶
Configuration of :class:ScoreComparisonPipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str
|
Root output directory. CSV files and the Excel report go to |
"output/score_comparison"
|
target_col
|
str
|
Binary target column (1 = bad). It must exist in the input data. |
"badflag"
|
score_cols
|
list of str or None
|
All score columns to compare. Without |
None
|
base_score
|
str or None
|
Baseline score column. |
None
|
comp_scores
|
list of str or None
|
Comparison score columns. |
None
|
weight_col
|
str or None
|
Sample-weight column (must exist in the data). It weights the performance tables ( |
None
|
split_col
|
str or None
|
Column with evaluation-set labels (any non-empty names such as |
None
|
random_state
|
int
|
Not used by this pipeline; kept so that all high-level Pipeline configs share the same interface. |
42
|
write_outputs
|
bool
|
Whether to write CSV files to |
True
|
write_excel
|
bool
|
Whether to write |
True
|
nbins
|
int
|
Number of bins for the performance tables, the gains tables and both cross-risk analyses. |
10
|
min_bin_prop
|
float
|
Minimum share of samples per bin. |
0.02
|
equal_freq
|
bool
|
Whether to use equal-frequency binning. |
True
|
min_data_size
|
int
|
Minimum number of rows a group value needs to be evaluated (smaller groups are skipped; a group with exactly
this many rows is evaluated, for single columns and crossed groups alike). It is also the default for
|
50
|
precision
|
int
|
Decimal precision of bin boundaries and of the score ranges (not applied to the |
5
|
include_missing
|
bool
|
Whether missing values get their own bin in the gains and cross-risk tables. The performance tables always
exclude missing scores. With |
False
|
fillna
|
any
|
Value used to fill missing scores before binning the gains tables and the |
-999999
|
positive_score_only
|
bool
|
In the performance tables a score counts as valid only where it is greater than 0, so zero, negative and missing scores are dropped (missing and infinite scores are never valid). It does not change the gains tables, and the pairwise cross always requires both scores to be greater than 0. |
True
|
perf_common_rows
|
bool
|
True evaluates every score of |
True
|
group_missing_values
|
list
|
Text values (compared after stripping whitespace) treated as missing in the grouping columns ( |
['', ' ', 'NA', 'NULL', 'nan']
|
drop_missing_group_values
|
bool
|
True sets those values to missing so that they do not form a group. False keeps them as ordinary group labels,
or as |
True
|
time_dims
|
list of str
|
Time columns; each one is evaluated as a group in |
['apply_month']
|
population_dims
|
list of str
|
Population columns; each one is evaluated as a group in |
['channel']
|
segment_dims
|
list of str or None
|
Alias of |
None
|
include_time_population_cross
|
bool
|
Whether to also evaluate every population column crossed with every time column (group name
|
True
|
group_min_size
|
int or None
|
Minimum rows per group value in the group evaluation (an entry of |
None
|
group_specs
|
dict or list or None
|
Custom grouping that replaces the automatic groups ( |
None
|
gains_add_func
|
callable or None
|
Function |
None
|
custom_metric_cols
|
list of str
|
Business columns averaged in the default gains metrics and used in the default |
['credit_limit', 'age', 'apr']
|
gains_display_metric_list
|
list of str
|
Gains columns to display. It is passed to the evaluation tool, which applies it only when no |
['MIN', 'MAX', 'N', 'PROP', 'AVG_SCORE', 'AVG_BAD', 'CUM_BAD_PCT', 'KS_PER_BIN', 'LIFT', 'RANK_ORDER_BUMP']
|
cross_vars
|
list of str
|
Second-dimension variables for |
[]
|
cross_metrics
|
dict
|
|
{}
|
cross_binning_numeric
|
list of bool or bool
|
|
[True, False]
|
pairwise_cross_enabled
|
bool
|
Whether to compute |
True
|
pairwise_cross_agg_dict
|
dict or None
|
|
None
|
Source code in Modeling_Tool/Pipeline/score_comparison.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
ScoreComparisonPipelineResult
dataclass
¶
Result returned by :meth:ScoreComparisonPipeline.run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
global_perf
|
DataFrame
|
Performance ( |
required |
group_perf
|
dict of str to pandas.DataFrame
|
Same performance metrics per group value, keyed by group name: |
required |
gains
|
DataFrame
|
Gains table of every score on the whole sample (one block of bins per |
required |
cross_results
|
dict of str to pandas.DataFrame
|
Cross-risk tables keyed |
required |
pairwise_cross
|
DataFrame or None
|
Long table with columns |
None
|
report_path
|
str or None
|
Path of the Excel report; None when |
None
|
Source code in Modeling_Tool/Pipeline/score_comparison.py
ScoreComparisonPipeline
¶
Reusable multi-score comparison workflow built on Model_Evaluation_Tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ScoreComparisonPipelineConfig or None
|
Pipeline configuration. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
config |
ScoreComparisonPipelineConfig
|
The configuration in use. |
Source code in Modeling_Tool/Pipeline/score_comparison.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
run
¶
run(data: DataFrame) -> ScoreComparisonPipelineResult
Compare the configured scores globally, per group, by gains and by cross risk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Scored sample. It must contain |
required |
Returns:
| Type | Description |
|---|---|
ScoreComparisonPipelineResult
|
Global and group performance, gains, cross-risk tables and the Excel report path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
KeyError
|
If a required column (target, scores, |
TypeError
|
If |
Source code in Modeling_Tool/Pipeline/score_comparison.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
Score Consistency UAT Pipeline: score_consistency_uat¶
score_consistency_uat
¶
ScoreConsistencyUATPipelineConfig
dataclass
¶
Configuration of :class:ScoreConsistencyUATPipeline.
Two data modes exist. In DataFrame mode (offline_data / online_data given here or to run) the frames are
used directly. In SQL mode the two SQL files are executed with sqlrunner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str
|
Root output directory. CSV files and the default Excel report go to |
"output/score_consistency_uat"
|
random_state
|
int
|
Not used by this pipeline; kept so that all high-level Pipeline configs share the same interface. |
42
|
write_outputs
|
bool
|
Whether to write the CSV tables |
True
|
write_excel
|
bool
|
Whether to export the Excel report with |
True
|
sql_dir
|
str
|
Directory that contains the SQL files (SQL mode). It is resolved to an absolute path. |
"sql"
|
offline_sql
|
str
|
File name, inside |
"pull_offline.sql"
|
online_sql
|
str
|
File name, inside |
"pull_online.sql"
|
sqlrunner
|
object or None
|
SQL runner whose |
None
|
env_path
|
str or None
|
Path of a |
None
|
n_process
|
int or str or None
|
Number of processes passed to |
"auto"
|
offline_data
|
DataFrame or None
|
Offline data for DataFrame mode; the |
None
|
online_data
|
DataFrame or None
|
Online data for DataFrame mode; the |
None
|
main_model_score_col
|
str
|
Name of the main model score column, identical offline and online. After the outer merge on |
"credit_risk_v31_cdc_submodel_score"
|
tol_score
|
float
|
Absolute tolerance for the main score and the dedicated submodel check. A row mismatches when
|
1e-06
|
tol_feat
|
float
|
Absolute tolerance for numeric feature pairs ( |
0.01
|
time_featlist
|
list of str
|
Time fields (same name offline and online) compared as datetimes with |
[]
|
tol_time_seconds
|
float
|
Tolerance in seconds on |
60.0
|
comparison_block_size
|
int
|
Number of feature columns compared per block when |
128
|
excel_output_path
|
str or None
|
Excel report path ( |
None
|
excel_font
|
str
|
Font name applied to the whole Excel report. |
"Arial"
|
info_list
|
list of str
|
Identifier columns (for example user_id or launch_time) written after |
[]
|
include_submodel_scores
|
bool
|
True: submodel scores are compared like any other feature and the dedicated submodel check is skipped.
False: run the dedicated check for |
True
|
submodel_pairs
|
dict of str to str
|
|
{}
|
numeric_coercion_mode
|
str
|
DataFrame mode only: how object-dtype columns of the merged frame become numeric. |
"safe"
|
numeric_coercion_min_ratio
|
float
|
DataFrame mode with |
0.99
|
Source code in Modeling_Tool/Pipeline/score_consistency_uat.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
ScoreConsistencyUATPipelineResult
dataclass
¶
Result returned by :meth:ScoreConsistencyUATPipeline.run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offline_data
|
DataFrame or None
|
Offline data held by the checker (a copy of the input in DataFrame mode). |
required |
online_data
|
DataFrame or None
|
Online data held by the checker (a copy of the input in DataFrame mode). |
required |
compare_data
|
DataFrame or None
|
Outer merge of the two frames on |
required |
both_data
|
DataFrame or None
|
Rows of |
required |
coverage_summary
|
dict
|
|
required |
main_score_summary
|
dict
|
Main score comparison: |
required |
submodel_summary
|
list of dict
|
One dict per |
required |
feature_diff_summary
|
DataFrame
|
One row per |
required |
time_summary
|
DataFrame
|
One row per |
required |
per_flow_report
|
DataFrame
|
One row per common |
required |
summary
|
DataFrame
|
Overall conclusion with columns |
required |
report_path
|
str or None
|
Path of the Excel report; None when |
None
|
checker
|
UATConsistencyChecker or None
|
The underlying checker, for access to intermediate attributes such as |
None
|
Source code in Modeling_Tool/Pipeline/score_consistency_uat.py
ScoreConsistencyUATPipeline
¶
Reusable online/offline score consistency UAT workflow.
Wraps Modeling_Tool.UAT.UATConsistencyChecker: loads the offline and online data (SQL files or DataFrames),
merges them on flow_id and checks coverage, main score, submodel scores, all features, time fields and
per-flow differences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ScoreConsistencyUATPipelineConfig or None
|
Pipeline configuration. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
config |
ScoreConsistencyUATPipelineConfig
|
The configuration in use. |
Source code in Modeling_Tool/Pipeline/score_consistency_uat.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | |
run
¶
run(offline_data: DataFrame | None = None, online_data: DataFrame | None = None) -> ScoreConsistencyUATPipelineResult
Run the consistency checks and write the configured reports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offline_data
|
DataFrame or None
|
Offline data; overrides |
None
|
online_data
|
DataFrame or None
|
Online data; overrides |
None
|
Returns:
| Type | Description |
|---|---|
ScoreConsistencyUATPipelineResult
|
The checker tables, the merged data, the Excel report path and the checker itself. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If only one of the two DataFrames is available, or if |
KeyError
|
If a DataFrame has no |
ImportError
|
If |
Notes
DataFrame mode is used as soon as one of the two frames is given (as argument or in the config); then both are
required. Otherwise the SQL files in sql_dir are run with config.sqlrunner (ODPSRunner() when None).
Source code in Modeling_Tool/Pipeline/score_consistency_uat.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
Sample Analysis Pipeline: sample_analysis¶
sample_analysis
¶
SampleAnalysisPipelineConfig
dataclass
¶
Configuration of :class:SampleAnalysisPipeline.
The defaults for the column names (target_cols, time_dims, population_dims, profile_cols,
approved_col) match one particular dataset. run raises KeyError when a configured column is missing from
the data, so override them for your own data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_cols
|
list of str
|
Candidate target label columns (1 = bad). Each target is analysed separately and only rows where the label is not null (mature rows) take part. |
['y_flag_dpd7_in_mob1', 'y_flag_dpd7_in_mob3', 'y_flag_dpd7_in_mob6', 'y_flag_dpd7_in_mob12']
|
time_col
|
str
|
Application time column; converted with |
"apply_time"
|
time_dims
|
list of str
|
Existing time-period columns used for the bad-rate and profile summaries (alone and crossed with
|
['apply_week', 'apply_month', 'apply_quarter']
|
population_dims
|
list of str
|
Existing population columns used for the bad-rate and profile summaries (alone and crossed with
|
['channel', 'strategy_version']
|
profile_cols
|
list of str
|
Columns profiled in |
['age', 'income', 'education', 'credit_limit']
|
oot_time_dim
|
str
|
Column whose sorted distinct values define the out-of-time (OOT) windows: the last |
"apply_month"
|
oot_windows
|
list of int
|
Candidate OOT window lengths |
[1, 2, 3, 6]
|
ins_oos_ratios
|
list of float
|
Candidate INS shares of the non-OOT pool; the OOS share is |
[0.7, 0.75, 0.8]
|
random_seeds
|
range or list of int or tuple of int
|
Random seeds tried for every INS/OOS split. The number of candidates per target is
|
range(3000, 3020)
|
min_sample_size
|
int
|
Minimum rows required in each of INS, OOS and OOT for a candidate to be eligible for the recommendation. If a target has no eligible candidate, all of its candidates are considered. |
500
|
output_dir
|
str
|
Directory for the CSV files, the Excel report and the optional split files. |
"output/sample_analysis"
|
write_outputs
|
bool
|
Whether to write the five summary tables as |
True
|
write_excel
|
bool
|
Whether to write |
True
|
approved_col
|
str or None
|
Approval flag column (1 = approved) used to count |
"is_approved"
|
dry_run
|
bool
|
True makes |
False
|
id_col
|
str or None
|
Unique row identifier column, required when |
None
|
materialize_split
|
bool
|
True replays the recommended (OOT window, ratio, seed) of every target into row-level INS/OOS/OOT labels
( |
False
|
oot_cutoff
|
any
|
Used only when |
None
|
split_col_name
|
str
|
Name of the label column in |
"sample_split"
|
persist_split_map
|
bool
|
With |
False
|
Source code in Modeling_Tool/Pipeline/sample_analysis.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
SampleAnalysisPipelineResult
dataclass
¶
Result returned by :meth:SampleAnalysisPipeline.run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label_coverage_summary
|
DataFrame
|
One row per target: |
required |
segment_bad_rate_summary
|
DataFrame
|
Mature-row counts and bad rates per target and group: |
required |
profile_summary
|
DataFrame
|
Same group keys as |
required |
split_candidate_summary
|
DataFrame
|
One row per target, OOT window, INS ratio and seed with the OOT periods, sample sizes ( |
required |
split_recommendation
|
DataFrame
|
One row per target: the eligible candidate with the smallest |
required |
output_paths
|
dict of str to str
|
Absolute paths of the files written: one entry per table name (CSV), |
required |
row_level_split
|
DataFrame or None
|
None unless |
None
|
split_artifact
|
dict or None
|
None unless |
None
|
Source code in Modeling_Tool/Pipeline/sample_analysis.py
SampleAnalysisPipeline
¶
Analyze label maturity, segment drift, and INS/OOS/OOT split stability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SampleAnalysisPipelineConfig or None
|
Pipeline configuration. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
config |
SampleAnalysisPipelineConfig
|
The configuration in use. |
Source code in Modeling_Tool/Pipeline/sample_analysis.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 | |
estimate_split_count
¶
Return an upper-bound estimate of split candidates that _split_candidates would produce.
If data is provided, refine the OOT window count against the actual number of
distinct oot_time_dim values available (some windows may collapse if history is short).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame or None
|
Optional data. When it contains the |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Notes
Nothing is computed from the labels, so the real number of candidates can be lower: a target without usable OOT and pool segments contributes none.
Source code in Modeling_Tool/Pipeline/sample_analysis.py
run
¶
run(data: DataFrame) -> SampleAnalysisPipelineResult
Run the label coverage, segment, profile and split-stability analyses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Sample to analyse. It must contain |
required |
Returns:
| Type | Description |
|---|---|
SampleAnalysisPipelineResult
|
The five summary tables, the paths of the files written and, with |
Raises:
| Type | Description |
|---|---|
KeyError
|
If a required column (or |
ValueError
|
If |
AssertionError
|
If the materialized INS, OOS and OOT segments overlap or do not cover all mature rows of a target. |
Notes
With dry_run=True the input is validated, a warning with the estimated split count is logged and the
analysis is skipped (see :meth:estimate_split_count). Existing output files are overwritten.
Source code in Modeling_Tool/Pipeline/sample_analysis.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
Mock Sample Pipeline: mock_sample¶
mock_sample
¶
MockSamplePipelineConfig
dataclass
¶
Configuration of :class:MockSamplePipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_samples
|
int
|
Number of full application rows generated before any filtering. Must be positive. With |
80000
|
applied_sample
|
int
|
|
1
|
approve_rate
|
float
|
Share of applications flagged |
0.25
|
num_online_scores
|
int
|
Number of simulated online bad-probability columns |
5
|
y_flag_candidates
|
list of int
|
Performance windows in days. One label column |
[15, 30, 45]
|
num_features
|
int
|
Number of random feature columns |
20
|
min_num_feature_business_type
|
int
|
Lower bound on the number of distinct business types covered by the features. It must be between 1 and
|
5
|
random_state
|
int
|
Seed of the NumPy random generator; the same configuration gives the same data (for a fixed
|
42
|
observation_timestamp
|
str or Timestamp or None
|
Observation date used to decide which labels have matured. Application times are drawn uniformly between
|
None
|
application_months
|
int
|
Length in months of the application window that ends at the observation date. Must be positive. |
18
|
write_csv
|
bool
|
Whether to write the generated data to |
False
|
output_path
|
str
|
CSV file path; parent directories are created. Used only when |
"output/mock_sample/mock_sample.csv"
|
Source code in Modeling_Tool/Pipeline/mock_sample.py
MockSamplePipelineResult
dataclass
¶
Result returned by :meth:MockSamplePipeline.run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Generated sample. Columns: |
required |
summary
|
DataFrame
|
Two columns |
required |
feature_metadata
|
DataFrame
|
One row per generated feature with columns |
required |
output_path
|
str or None
|
Absolute path of the CSV file that was written, or None when |
required |
Source code in Modeling_Tool/Pipeline/mock_sample.py
MockSamplePipeline
¶
Generate synthetic application or approved samples for SMF demos.
The pipeline only produces data (and optionally a CSV file); it runs no modelling analysis and writes no Excel report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MockSamplePipelineConfig or None
|
Pipeline configuration. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
config |
MockSamplePipelineConfig
|
The configuration in use. |
Source code in Modeling_Tool/Pipeline/mock_sample.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
run
¶
run() -> MockSamplePipelineResult
Generate the sample described by the configuration.
Returns:
| Type | Description |
|---|---|
MockSamplePipelineResult
|
Generated |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the configuration is invalid (see :class: |
Notes
Labels exist only for approved applications; is_approved is 1 for them. The apply_week column uses the ISO
week format %G-W%V.
Source code in Modeling_Tool/Pipeline/mock_sample.py
Modeling from Validation Results: orchestrator¶
orchestrator
¶
High-level orchestration helpers across SMF pipelines.
run_modeling_from_validation
¶
run_modeling_from_validation(data: DataFrame, *, fvp_config: FeatureValidationPipelineConfig | None = None, cm_config: CreditModelPipelineConfig | None = None, selection_enabled: bool = True, reuse_screening_woe: bool = True) -> tuple[FeatureValidationPipelineResult, CreditModelPipelineResult]
Run feature validation/selection, then credit modeling on the same dataset.
The feature-validation result is turned into a FeatureScreeningArtifact, which is handed to the credit-model
pipeline: the artifact's target_col and weight_col replace those of cm_config (a UserWarning names a
column of cm_config that is replaced by another one), and its selected features replace cm_config.feature_cols
when there are any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The dataset both pipelines run on. |
required |
fvp_config
|
FeatureValidationPipelineConfig or None
|
Settings of the feature-validation pipeline; None uses the defaults. |
None
|
cm_config
|
CreditModelPipelineConfig or None
|
Settings of the credit-model pipeline; None uses the defaults. |
None
|
selection_enabled
|
bool
|
When True and |
True
|
reuse_screening_woe
|
bool
|
Passed to the credit-model config as |
True
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
Source code in Modeling_Tool/Pipeline/orchestrator.py
Screening Artifact: screening_artifact¶
screening_artifact
¶
Handoff contract between feature validation and credit modeling pipelines.
FeatureScreeningArtifact
dataclass
¶
Handoff contract between feature validation and credit modeling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selected_features
|
list of str
|
Features that survived the screening. |
required |
selection_summary
|
dict
|
The screening summary in the layout of |
required |
woe_artifacts
|
dict or None
|
Reusable WOE engines and tables, or None when the screen did not keep any. |
required |
source
|
('fvp', 'cm', 'standalone')
|
Which pipeline produced the artifact. |
"fvp"
|
target_col
|
str
|
Target the screening was run for. |
required |
weight_col
|
str or None
|
Sample-weight column used by the screening, or None. |
required |
config_snapshot
|
dict
|
Copy of the configuration that produced the screening. |
empty dict
|
created_at
|
str or None
|
UTC creation time in ISO format. |
None
|
Source code in Modeling_Tool/Pipeline/screening_artifact.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
from_screen_result
classmethod
¶
from_screen_result(result: WeightedScreenResult, *, initial_features: list[str], target_col: str, weight_col: str | None, woe_artifacts: dict[str, Any] | None, source: Literal['fvp', 'cm', 'standalone'], config_snapshot: dict[str, Any] | None = None) -> FeatureScreeningArtifact
Build an artifact from the result of a weighted feature screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
WeightedScreenResult
|
Result of the screen. |
required |
initial_features
|
list of str
|
The features that entered the screen. |
required |
target_col
|
str
|
Target the screen was run for. |
required |
weight_col
|
str or None
|
Sample-weight column used by the screen. |
required |
woe_artifacts
|
dict or None
|
WOE artifacts to store; when None or empty, the engine that the screen itself fitted is wrapped (if there is one). |
required |
source
|
('fvp', 'cm', 'standalone')
|
Which pipeline produced the result. |
"fvp"
|
config_snapshot
|
dict or None
|
Copy of the configuration to store. |
None
|
Returns:
| Type | Description |
|---|---|
FeatureScreeningArtifact
|
|
Source code in Modeling_Tool/Pipeline/screening_artifact.py
from_fvp_result
classmethod
¶
from_fvp_result(result: Any, *, target_col: str | None = None, weight_col: str | None = None) -> FeatureScreeningArtifact
Build an artifact from a feature-validation pipeline result.
When the result already carries a screening_artifact it is returned unchanged. Otherwise the artifact is built
from the result's selection_summary and config_snapshot. If the pipeline ran with selection switched off
and selected nothing, the configured new_feature_cols become the selected features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
FeatureValidationPipelineResult
|
Result of a feature-validation run. |
required |
target_col
|
str or None
|
Target column; when None it is read from the summary, then from the config snapshot ( |
None
|
weight_col
|
str or None
|
Weight column. A |
None
|
Returns:
| Type | Description |
|---|---|
FeatureScreeningArtifact
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no target column can be determined. |
Source code in Modeling_Tool/Pipeline/screening_artifact.py
validate_for_cm
¶
Check that the artifact was built for the same target and weight columns as a credit-model run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_col
|
str
|
Target column of the credit-model configuration. |
required |
weight_col
|
str or None
|
Weight column of the credit-model configuration. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the artifact's |
Source code in Modeling_Tool/Pipeline/screening_artifact.py
to_dict
¶
Return the artifact as a dictionary; top-level DataFrame values become lists of records.
Source code in Modeling_Tool/Pipeline/screening_artifact.py
iv_table_for_summary
¶
The iv table of a feature_selection_summary: iv_table with iv_weighted named iv.
Since 0.9.2 iv_table carries iv itself (equal to iv_weighted), so iv_weighted is dropped instead of
renamed and the summary keeps one iv column, followed by iv_raw, iv_sv_pure and n_sv_pure.
Source code in Modeling_Tool/Pipeline/screening_artifact.py
screen_result_to_summary
¶
screen_result_to_summary(result: WeightedScreenResult, initial_features: list[str]) -> dict[str, Any]
Convert a screening result into CM-compatible feature_selection_summary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
WeightedScreenResult
|
Result of a weighted feature screen. |
required |
initial_features
|
list of str
|
The features that entered the screen. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Always |
Source code in Modeling_Tool/Pipeline/screening_artifact.py
woe_artifacts_from_screen_result
¶
woe_artifacts_from_screen_result(result: WeightedScreenResult, target_col: str) -> dict[str, Any] | None
Wrap a screen-fitted WOE engine into the CM reuse contract (G00).
The returned dict matches what CreditModelPipeline._reuse_screening_woe
consumes: by_target[target] = {engine, adapter, features} plus a
top-level woe_table and the engine_meta of the screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
WeightedScreenResult
|
Result of a weighted feature screen; its |
required |
target_col
|
str
|
Target the engine was fitted for; it becomes the key of |
required |
Returns:
| Type | Description |
|---|---|
dict or None
|
The reuse payload, or None when the screen did not attach a reusable engine (for example WOE_Master screens attach table-only metadata). |
Source code in Modeling_Tool/Pipeline/screening_artifact.py
Config Schema and Registry: field_meta¶
Helpers for building a configuration GUI or loading configs from YAML. See Pipeline GUI Schema.
field_meta
¶
FieldMeta
dataclass
¶
Human-readable metadata for a Pipeline Config field.
The metadata is intentionally dependency-free so that GUI applications can introspect SMF configs without importing Streamlit or any frontend package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
Short display name of the field. |
required |
description
|
str
|
Help text for the field. For fields without curated text it repeats |
required |
widget
|
('text', 'number', 'select', 'multiselect', 'toggle', 'slider', 'textarea', 'json', 'hidden')
|
Suggested form control. |
"text"
|
options
|
list or None
|
Allowed values for the |
None
|
min_val
|
float or None
|
Lower bound hint for numeric controls such as sliders. |
None
|
max_val
|
float or None
|
Upper bound hint for numeric controls such as sliders. |
None
|
step
|
float or None
|
Step hint for numeric controls such as sliders. |
None
|
required
|
bool
|
Whether a form should ask for this field. It comes from a fixed list per Pipeline and does not mean that the dataclass field has no default. |
False
|
group
|
str
|
Name of the suggested form section. |
"Basic settings"
|
depends_on
|
dict or None
|
Display condition |
None
|
since_version
|
str or None
|
Version that introduced the field, when recorded. |
None
|
is_dict_subkey
|
bool
|
True when the metadata describes a key inside a dictionary-valued config field (see |
False
|
parent_field
|
str or None
|
Name of the dictionary-valued field that owns this sub-key. |
None
|
yaml_serializable
|
bool
|
False for objects that cannot be written to YAML/JSON (DataFrames, callables, connections, artifacts). |
True
|
gui_editable
|
bool
|
False for fields that a GUI should not render (the same code-only objects). |
True
|
advanced
|
bool
|
Hint to collapse the field under an "advanced" section. |
False
|
expert_only
|
bool
|
Hint that the field is meant for expert users only. |
False
|
placeholder
|
str or None
|
Example text for an empty input control. |
None
|
nested_fields
|
list of FieldMeta
|
Metadata of the known keys of a dictionary-valued field (for example |
empty list
|
Source code in Modeling_Tool/Pipeline/field_meta.py
to_dict
¶
PipelineRegistryEntry
dataclass
¶
One high-level Pipeline in the registry: card text, classes and how to call it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Registry key, for example |
required |
display_name
|
str
|
Title for a Pipeline card. |
required |
description
|
str
|
What the Pipeline does. |
required |
use_case
|
str
|
When to use it. |
required |
audience
|
list of str
|
Reader roles the Pipeline is meant for. |
required |
pipeline_class
|
type
|
The Pipeline class. |
required |
config_class
|
type
|
The Config dataclass the Pipeline takes. |
required |
result_class
|
type
|
The result dataclass that |
required |
module_path
|
str
|
Dotted path of the module that defines the classes. |
required |
import_path
|
str
|
Package that exports the classes; generated code imports from here. |
"Modeling_Tool.Pipeline"
|
run_requires_data
|
bool
|
False when |
True
|
run_method
|
str
|
The call to show on a card. |
"run(data=your_dataframe)"
|
result_attrs
|
list of str
|
Headline attributes of the result object. |
empty list
|
Source code in Modeling_Tool/Pipeline/field_meta.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
to_dict
¶
Return the entry as a plain dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_classes
|
bool
|
When True, also include the |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
The entry fields; the classes appear as |
Source code in Modeling_Tool/Pipeline/field_meta.py
get_pipeline_registry
¶
Return the public high-level Pipeline registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_classes
|
bool
|
When True, each entry includes actual class objects. Set False for a JSON/YAML-friendly registry payload. |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
Registry key to entry dictionary (see |
Source code in Modeling_Tool/Pipeline/field_meta.py
get_pipeline_registry_schema
¶
Return a JSON-serializable registry summary without class objects.
Returns:
| Type | Description |
|---|---|
dict
|
Registry key to entry dictionary, with class names instead of class objects. |
Source code in Modeling_Tool/Pipeline/field_meta.py
get_config_field_meta
¶
get_config_field_meta(config_class_or_key: str | type | Any) -> dict[str, FieldMeta]
Return FieldMeta objects keyed by config field name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_class_or_key
|
(str, type or object)
|
A registry key (for example |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Field name to |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the reference does not match a registered Pipeline. |
Source code in Modeling_Tool/Pipeline/field_meta.py
extract_config_schema
¶
Extract a GUI-friendly schema for one Pipeline Config class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_class_or_key
|
(str, type or object)
|
A registry key (for example |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The registry card of the Pipeline ( |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the reference does not match a registered Pipeline. |
Source code in Modeling_Tool/Pipeline/field_meta.py
extract_pipeline_schema
¶
Extract one schema or all pipeline schemas.
Passing None returns {"pipelines": {...}} for all registered pipelines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_key
|
(str, type, object or None)
|
A registry key, a Config, Pipeline or result class (or its name), or an instance of one of them. None selects every registered Pipeline. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The result of |
Source code in Modeling_Tool/Pipeline/field_meta.py
extract_schema
¶
Compatibility helper returning just the list of field schemas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_class_or_key
|
(str, type or object)
|
A registry key (for example |
required |
Returns:
| Type | Description |
|---|---|
list of dict
|
The |
Source code in Modeling_Tool/Pipeline/field_meta.py
config_to_dict
¶
config_to_dict(config: Any, *, include_non_serializable: bool = False, exclude_none: bool = False) -> dict[str, Any]
Convert a Pipeline Config dataclass to a plain dict.
Non-serializable object fields (DataFrame, callable, sqlrunner, artifacts) are skipped by default, which is the safest behavior for GUI/YAML export.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dataclass instance
|
A Pipeline Config object. |
required |
include_non_serializable
|
bool
|
When False, fields flagged as not YAML-serializable and values that cannot be converted are skipped, and the
other values are converted to plain data (tuples and ranges become lists, paths become strings). When True,
every field is kept: convertible values are stored unchanged and the others are replaced by their |
False
|
exclude_none
|
bool
|
Skip fields whose value is None. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Field name to value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in Modeling_Tool/Pipeline/field_meta.py
config_from_dict
¶
config_from_dict(config_class_or_key: str | type, payload: dict[str, Any], *, strict: bool = True) -> Any
Instantiate a Pipeline Config from a dict or GUI/YAML payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_class_or_key
|
str or type
|
A registry key, a Config, Pipeline or result class name, or one of those classes. |
required |
payload
|
dict
|
Field values. A mapping that has a |
required |
strict
|
bool
|
When True, unknown field names raise |
True
|
Returns:
| Type | Description |
|---|---|
object
|
An instance of the Config class; fields that are not in |
Raises:
| Type | Description |
|---|---|
KeyError
|
For an unknown reference, or for unknown field names when |
Source code in Modeling_Tool/Pipeline/field_meta.py
config_to_yaml
¶
config_to_yaml(config: Any, *, pipeline_key: str | None = None, include_non_serializable: bool = False) -> str
Serialize a Pipeline Config dataclass to a GUI-friendly YAML payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dataclass instance
|
A Pipeline Config object. |
required |
pipeline_key
|
str or None
|
Registry key of the Pipeline. When None it is inferred from the class of |
None
|
include_non_serializable
|
bool
|
Passed to |
False
|
Returns:
| Type | Description |
|---|---|
str
|
YAML text with the keys |
Raises:
| Type | Description |
|---|---|
ImportError
|
If PyYAML is not installed. |
Source code in Modeling_Tool/Pipeline/field_meta.py
config_from_yaml
¶
config_from_yaml(config_class_or_key: str | type | None, yaml_text: str, *, strict: bool = True) -> Any
Deserialize a Pipeline Config from a YAML payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_class_or_key
|
(str, type or None)
|
A registry key or a Config class. When None, the |
required |
yaml_text
|
str
|
YAML text, for example the output of |
required |
strict
|
bool
|
When True, unknown field names raise |
True
|
Returns:
| Type | Description |
|---|---|
object
|
An instance of the Config class. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If PyYAML is not installed. |
TypeError
|
If the YAML text is not a mapping. |
KeyError
|
If no Pipeline can be determined, or for unknown field names when |
Source code in Modeling_Tool/Pipeline/field_meta.py
validate_pipeline_config
¶
Lightweight config-only validation for GUI forms.
The Pipeline run methods remain the authoritative runtime validation,
but this helper catches common form mistakes before code generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_key
|
str
|
A registry key (or the name of a Config, Pipeline or result class). |
required |
values
|
dict or Config instance
|
The form values. A key that is left out counts as unset: required keys are reported as empty and the others fall back to the Config default. Unknown keys are not reported. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
Error messages first, then warnings, each warning prefixed with |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in Modeling_Tool/Pipeline/field_meta.py
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 | |
generate_pipeline_code
¶
Generate a minimal Python snippet for a configured Pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_key
|
str
|
A registry key (or the name of a Config, Pipeline or result class). |
required |
values
|
dict
|
Field name to value. Each value is written with |
required |
Returns:
| Type | Description |
|---|---|
str
|
Code that imports the Pipeline and Config classes, builds the Config from |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |