ins-pricing 0.4.4__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/MANIFEST.in +3 -3
  2. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/PKG-INFO +55 -35
  3. ins_pricing-0.5.0/README.md +130 -0
  4. ins_pricing-0.5.0/ins_pricing/README.md +92 -0
  5. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/__init__.py +142 -90
  6. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/BayesOpt_entry.py +52 -50
  7. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/BayesOpt_incremental.py +832 -898
  8. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/Explain_Run.py +31 -23
  9. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/Explain_entry.py +532 -579
  10. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/Pricing_Run.py +31 -23
  11. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/bayesopt_entry_runner.py +1440 -1438
  12. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/utils/cli_common.py +256 -256
  13. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/utils/cli_config.py +375 -375
  14. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/utils/import_resolver.py +382 -365
  15. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/utils/notebook_utils.py +340 -340
  16. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/watchdog_run.py +209 -201
  17. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/frontend/README.md +573 -419
  18. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/frontend/__init__.py +10 -10
  19. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/frontend/config_builder.py +1 -0
  20. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/frontend/example_workflows.py +1 -1
  21. ins_pricing-0.5.0/ins_pricing/governance/__init__.py +20 -0
  22. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/governance/release.py +159 -159
  23. ins_pricing-0.5.0/ins_pricing/modelling/README.md +67 -0
  24. ins_pricing-0.5.0/ins_pricing/modelling/__init__.py +150 -0
  25. ins_pricing-0.5.0/ins_pricing/modelling/bayesopt/README.md +59 -0
  26. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/__init__.py +64 -102
  27. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/config_preprocess.py +562 -550
  28. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/core.py +965 -962
  29. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/model_explain_mixin.py +296 -296
  30. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/model_plotting_mixin.py +482 -548
  31. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/models/__init__.py +27 -27
  32. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/models/model_ft_trainer.py +915 -913
  33. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/models/model_gnn.py +788 -785
  34. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/models/model_resn.py +448 -446
  35. ins_pricing-0.5.0/ins_pricing/modelling/bayesopt/trainers/__init__.py +19 -0
  36. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/trainers/trainer_base.py +1308 -1308
  37. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/trainers/trainer_ft.py +3 -3
  38. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/trainers/trainer_glm.py +197 -198
  39. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/trainers/trainer_gnn.py +344 -344
  40. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/trainers/trainer_resn.py +283 -283
  41. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/trainers/trainer_xgb.py +346 -347
  42. ins_pricing-0.5.0/ins_pricing/modelling/bayesopt/utils/__init__.py +67 -0
  43. ins_pricing-0.5.0/ins_pricing/modelling/bayesopt/utils/constants.py +21 -0
  44. ins_pricing-0.5.0/ins_pricing/modelling/bayesopt/utils/io_utils.py +7 -0
  45. ins_pricing-0.5.0/ins_pricing/modelling/bayesopt/utils/losses.py +27 -0
  46. ins_pricing-0.5.0/ins_pricing/modelling/bayesopt/utils/metrics_and_devices.py +17 -0
  47. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/utils/torch_trainer_mixin.py +623 -623
  48. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/evaluation.py +113 -104
  49. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/explain/__init__.py +55 -55
  50. ins_pricing-0.5.0/ins_pricing/modelling/explain/metrics.py +29 -0
  51. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/explain/permutation.py +237 -237
  52. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/plotting/__init__.py +40 -36
  53. ins_pricing-0.5.0/ins_pricing/modelling/plotting/compat.py +228 -0
  54. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/plotting/curves.py +572 -572
  55. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/plotting/diagnostics.py +163 -163
  56. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/plotting/geo.py +362 -362
  57. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/plotting/importance.py +121 -121
  58. ins_pricing-0.5.0/ins_pricing/pricing/__init__.py +27 -0
  59. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/production/__init__.py +35 -25
  60. ins_pricing-0.4.4/ins_pricing/production/predict.py → ins_pricing-0.5.0/ins_pricing/production/inference.py +140 -57
  61. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/production/monitoring.py +8 -21
  62. ins_pricing-0.5.0/ins_pricing/reporting/__init__.py +11 -0
  63. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/setup.py +1 -1
  64. ins_pricing-0.5.0/ins_pricing/tests/production/test_inference.py +90 -0
  65. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/utils/__init__.py +116 -83
  66. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/utils/device.py +255 -255
  67. ins_pricing-0.5.0/ins_pricing/utils/features.py +53 -0
  68. ins_pricing-0.5.0/ins_pricing/utils/io.py +72 -0
  69. {ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt → ins_pricing-0.5.0/ins_pricing}/utils/losses.py +125 -129
  70. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/utils/metrics.py +158 -24
  71. ins_pricing-0.5.0/ins_pricing/utils/numerics.py +76 -0
  72. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/utils/paths.py +9 -1
  73. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing.egg-info/PKG-INFO +55 -35
  74. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing.egg-info/SOURCES.txt +35 -41
  75. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/pyproject.toml +1 -1
  76. ins_pricing-0.4.4/README.md +0 -110
  77. ins_pricing-0.4.4/ins_pricing/CHANGELOG.md +0 -272
  78. ins_pricing-0.4.4/ins_pricing/README.md +0 -74
  79. ins_pricing-0.4.4/ins_pricing/RELEASE_NOTES_0.2.8.md +0 -344
  80. ins_pricing-0.4.4/ins_pricing/docs/LOSS_FUNCTIONS.md +0 -78
  81. ins_pricing-0.4.4/ins_pricing/docs/modelling/BayesOpt_USAGE.md +0 -945
  82. ins_pricing-0.4.4/ins_pricing/docs/modelling/README.md +0 -34
  83. ins_pricing-0.4.4/ins_pricing/frontend/QUICKSTART.md +0 -152
  84. ins_pricing-0.4.4/ins_pricing/governance/__init__.py +0 -20
  85. ins_pricing-0.4.4/ins_pricing/modelling/__init__.py +0 -95
  86. ins_pricing-0.4.4/ins_pricing/modelling/core/BayesOpt.py +0 -146
  87. ins_pricing-0.4.4/ins_pricing/modelling/core/__init__.py +0 -1
  88. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/PHASE2_REFACTORING_SUMMARY.md +0 -449
  89. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/PHASE3_REFACTORING_SUMMARY.md +0 -406
  90. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/REFACTORING_SUMMARY.md +0 -247
  91. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/trainers/__init__.py +0 -19
  92. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/utils/__init__.py +0 -86
  93. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/utils/constants.py +0 -183
  94. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/utils/io_utils.py +0 -126
  95. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/utils/metrics_and_devices.py +0 -555
  96. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/utils.py +0 -105
  97. ins_pricing-0.4.4/ins_pricing/modelling/core/bayesopt/utils_backup.py +0 -1503
  98. ins_pricing-0.4.4/ins_pricing/modelling/explain/metrics.py +0 -176
  99. ins_pricing-0.4.4/ins_pricing/pricing/__init__.py +0 -27
  100. ins_pricing-0.4.4/ins_pricing/reporting/__init__.py +0 -11
  101. ins_pricing-0.4.4/ins_pricing/tests/production/test_predict.py +0 -233
  102. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/__init__.py +0 -0
  103. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/utils/__init__.py +0 -0
  104. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/utils/evaluation_context.py +0 -0
  105. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/cli/utils/run_logging.py +0 -0
  106. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/exceptions.py +0 -0
  107. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/frontend/app.py +0 -0
  108. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/frontend/example_config.json +0 -0
  109. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/frontend/ft_workflow.py +0 -0
  110. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/frontend/runner.py +0 -0
  111. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/governance/README.md +0 -0
  112. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/governance/approval.py +0 -0
  113. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/governance/audit.py +0 -0
  114. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/governance/registry.py +0 -0
  115. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/config_components.py +0 -0
  116. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/models/model_ft_components.py +0 -0
  117. {ins_pricing-0.4.4/ins_pricing/modelling/core → ins_pricing-0.5.0/ins_pricing/modelling}/bayesopt/utils/distributed_utils.py +0 -0
  118. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/explain/gradients.py +0 -0
  119. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/explain/shap_utils.py +0 -0
  120. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/modelling/plotting/common.py +0 -0
  121. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/pricing/README.md +0 -0
  122. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/pricing/calibration.py +0 -0
  123. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/pricing/data_quality.py +0 -0
  124. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/pricing/exposure.py +0 -0
  125. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/pricing/factors.py +0 -0
  126. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/pricing/monitoring.py +0 -0
  127. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/pricing/rate_table.py +0 -0
  128. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/production/drift.py +0 -0
  129. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/production/preprocess.py +0 -0
  130. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/production/scoring.py +0 -0
  131. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/reporting/README.md +0 -0
  132. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/reporting/report_builder.py +0 -0
  133. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/reporting/scheduler.py +0 -0
  134. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/governance/__init__.py +0 -0
  135. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/governance/test_audit.py +0 -0
  136. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/governance/test_registry.py +0 -0
  137. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/governance/test_release.py +0 -0
  138. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/conftest.py +0 -0
  139. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/test_cross_val_generic.py +0 -0
  140. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/test_distributed_utils.py +0 -0
  141. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/test_explain.py +0 -0
  142. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/test_geo_tokens_split.py +0 -0
  143. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/test_graph_cache.py +0 -0
  144. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/test_plotting.py +0 -0
  145. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/test_plotting_library.py +0 -0
  146. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/modelling/test_preprocessor.py +0 -0
  147. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/pricing/__init__.py +0 -0
  148. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/pricing/test_calibration.py +0 -0
  149. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/pricing/test_exposure.py +0 -0
  150. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/pricing/test_factors.py +0 -0
  151. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/pricing/test_rate_table.py +0 -0
  152. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/production/__init__.py +0 -0
  153. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/production/test_monitoring.py +0 -0
  154. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/production/test_preprocess.py +0 -0
  155. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/tests/production/test_scoring.py +0 -0
  156. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/utils/logging.py +0 -0
  157. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/utils/profiling.py +0 -0
  158. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/utils/torch_compat.py +0 -0
  159. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing/utils/validation.py +0 -0
  160. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing.egg-info/dependency_links.txt +0 -0
  161. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing.egg-info/requires.txt +0 -0
  162. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/ins_pricing.egg-info/top_level.txt +0 -0
  163. {ins_pricing-0.4.4 → ins_pricing-0.5.0}/setup.cfg +0 -0
@@ -1,3 +1,3 @@
1
- include README.md
2
- recursive-include ins_pricing *.md
3
- recursive-exclude ins_pricing/examples *
1
+ include README.md
2
+ recursive-include ins_pricing *.md
3
+ recursive-exclude examples *
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ins_pricing
3
- Version: 0.4.4
3
+ Version: 0.5.0
4
4
  Summary: Reusable modelling, pricing, governance, and reporting utilities.
5
5
  Author: meishi125478
6
6
  License: Proprietary
@@ -56,18 +56,19 @@ A reusable toolkit for insurance modeling, pricing, governance, and reporting.
56
56
 
57
57
  ## Overview
58
58
 
59
- Insurance-Pricing (ins_pricing) is an enterprise-grade Python library designed for machine learning model training, pricing calculations, and model governance workflows in the insurance industry.
59
+ Insurance-Pricing (ins_pricing) is an enterprise-grade Python library designed for machine learning
60
+ model training, pricing calculations, and model governance workflows in the insurance industry.
60
61
 
61
62
  ### Core Modules
62
63
 
63
64
  | Module | Description |
64
65
  |--------|-------------|
65
- | **modelling** | ML model training (GLM, XGBoost, ResNet, FT-Transformer, GNN) and model interpretability (SHAP, permutation importance) |
66
- | **pricing** | Factor table construction, numeric binning, premium calibration, exposure calculation, PSI monitoring |
67
- | **production** | Model prediction, batch scoring, data drift detection, production metrics monitoring |
68
- | **governance** | Model registry, version management, approval workflows, audit logging |
69
- | **reporting** | Report generation (Markdown format), report scheduling |
70
- | **utils** | Data validation, performance profiling, device management, logging configuration |
66
+ | modelling | ML model training (GLM, XGBoost, ResNet, FT-Transformer, GNN) and model interpretability |
67
+ | pricing | Factor table construction, numeric binning, premium calibration, exposure calculation, PSI monitoring |
68
+ | production | Model prediction, batch scoring, data drift detection, production metrics monitoring |
69
+ | governance | Model registry, version management, approval workflows, audit logging |
70
+ | reporting | Report generation (Markdown format), report scheduling |
71
+ | utils | Data validation, performance profiling, device management, logging configuration |
71
72
 
72
73
  ### Quick Start
73
74
 
@@ -110,17 +111,17 @@ registry.register(model_name, version, metrics=metrics)
110
111
 
111
112
  ```
112
113
  ins_pricing/
113
- ├── cli/ # Command-line entry points
114
- ├── modelling/
115
- │ ├── core/bayesopt/ # ML model training core
116
- │ ├── explain/ # Model interpretability
117
- │ └── plotting/ # Model visualization
118
- ├── pricing/ # Insurance pricing module
119
- ├── production/ # Production deployment module
120
- ├── governance/ # Model governance
121
- ├── reporting/ # Report generation
122
- ├── utils/ # Utilities
123
- └── tests/ # Test suite
114
+ cli/ # Command-line entry points
115
+ modelling/
116
+ core/bayesopt/ # ML model training core
117
+ explain/ # Model interpretability
118
+ plotting/ # Model visualization
119
+ pricing/ # Insurance pricing module
120
+ production/ # Production deployment module
121
+ governance/ # Model governance
122
+ reporting/ # Report generation
123
+ utils/ # Utilities
124
+ tests/ # Test suite
124
125
  ```
125
126
 
126
127
  ### Installation
@@ -139,24 +140,43 @@ pip install ins_pricing[plotting] # Visualization
139
140
  pip install ins_pricing[gnn] # Graph neural networks
140
141
  ```
141
142
 
142
- #### Multi-platform & GPU installation notes
143
+ #### Multi-platform and GPU notes
143
144
 
144
- - **PyTorch (CPU/GPU/MPS)**: Install the correct PyTorch build for your platform/GPU first (CUDA on
145
- Linux/Windows, ROCm on supported AMD platforms, or MPS on Apple Silicon). Then install the
146
- optional extras you need (e.g., `bayesopt`, `explain`, or `gnn`). This avoids pip pulling a
147
- mismatched wheel.
148
- - **Torch Geometric (GNN)**: `torch-geometric` often requires platform-specific wheels (e.g.,
149
- `torch-scatter`, `torch-sparse`). Follow the official PyG installation instructions for your
150
- CUDA/ROCm/CPU environment, then install `ins_pricing[gnn]`.
151
- - **Multi-GPU**: Training code will use CUDA when available and can enable multi-GPU via
152
- `torch.distributed`/`DataParallel` where supported. On Windows, CUDA DDP is not supported and will
153
- fall back to single-GPU or DataParallel where possible.
145
+ - Install the correct PyTorch build for your platform/GPU before installing extras.
146
+ - Torch Geometric requires platform-specific wheels; follow the official PyG install guide.
147
+ - Multi-GPU uses torch.distributed/DataParallel where supported; Windows disables CUDA DDP.
154
148
 
155
- ### Requirements
149
+ ---
150
+ ## PyPI Upload (scripts)
156
151
 
157
- - Python >= 3.9
158
- - Core dependencies: numpy >= 1.20, pandas >= 1.4
152
+ This repo includes upload scripts for Windows and Linux/macOS.
159
153
 
160
- ### License
154
+ ### Windows
161
155
 
162
- Proprietary
156
+ ```cmd
157
+ set TWINE_PASSWORD=your_pypi_token_here
158
+ python -m build
159
+ upload_to_pypi.bat
160
+ ```
161
+
162
+ ### Linux / macOS
163
+
164
+ ```bash
165
+ chmod +x upload_to_pypi.sh
166
+ export TWINE_PASSWORD='your_pypi_token_here'
167
+ python -m build
168
+ ./upload_to_pypi.sh
169
+ ```
170
+
171
+ ### Makefile (if make is available)
172
+
173
+ ```bash
174
+ make build
175
+ make upload
176
+ ```
177
+
178
+ ### Tips
179
+
180
+ - Never commit tokens to version control.
181
+ - Use environment variables or secret managers to store credentials.
182
+ - Test with TestPyPI before publishing when needed.
@@ -0,0 +1,130 @@
1
+ # Insurance-Pricing
2
+
3
+ A reusable toolkit for insurance modeling, pricing, governance, and reporting.
4
+
5
+ ## Overview
6
+
7
+ Insurance-Pricing (ins_pricing) is an enterprise-grade Python library designed for machine learning
8
+ model training, pricing calculations, and model governance workflows in the insurance industry.
9
+
10
+ ### Core Modules
11
+
12
+ | Module | Description |
13
+ |--------|-------------|
14
+ | modelling | ML model training (GLM, XGBoost, ResNet, FT-Transformer, GNN) and model interpretability |
15
+ | pricing | Factor table construction, numeric binning, premium calibration, exposure calculation, PSI monitoring |
16
+ | production | Model prediction, batch scoring, data drift detection, production metrics monitoring |
17
+ | governance | Model registry, version management, approval workflows, audit logging |
18
+ | reporting | Report generation (Markdown format), report scheduling |
19
+ | utils | Data validation, performance profiling, device management, logging configuration |
20
+
21
+ ### Quick Start
22
+
23
+ ```python
24
+ # Model training with Bayesian optimization
25
+ from ins_pricing import bayesopt as ropt
26
+
27
+ model = ropt.BayesOptModel(
28
+ train_data, test_data,
29
+ model_name='my_model',
30
+ resp_nme='target',
31
+ weight_nme='weight',
32
+ factor_nmes=feature_list,
33
+ cate_list=categorical_features,
34
+ )
35
+ model.bayesopt_xgb(max_evals=100) # Train XGBoost
36
+ model.bayesopt_resnet(max_evals=50) # Train ResNet
37
+ model.bayesopt_ft(max_evals=50) # Train FT-Transformer
38
+
39
+ # Pricing: build factor table
40
+ from ins_pricing.pricing import build_factor_table
41
+ factors = build_factor_table(
42
+ df,
43
+ factor_col='age_band',
44
+ loss_col='claim_amount',
45
+ exposure_col='exposure',
46
+ )
47
+
48
+ # Production: batch scoring
49
+ from ins_pricing.production import batch_score
50
+ scores = batch_score(model.trainers['xgb'].predict, df)
51
+
52
+ # Model governance
53
+ from ins_pricing.governance import ModelRegistry
54
+ registry = ModelRegistry('models.json')
55
+ registry.register(model_name, version, metrics=metrics)
56
+ ```
57
+
58
+ ### Project Structure
59
+
60
+ ```
61
+ ins_pricing/
62
+ cli/ # Command-line entry points
63
+ modelling/
64
+ core/bayesopt/ # ML model training core
65
+ explain/ # Model interpretability
66
+ plotting/ # Model visualization
67
+ pricing/ # Insurance pricing module
68
+ production/ # Production deployment module
69
+ governance/ # Model governance
70
+ reporting/ # Report generation
71
+ utils/ # Utilities
72
+ tests/ # Test suite
73
+ ```
74
+
75
+ ### Installation
76
+
77
+ ```bash
78
+ # Basic installation
79
+ pip install ins_pricing
80
+
81
+ # Full installation (all optional dependencies)
82
+ pip install ins_pricing[all]
83
+
84
+ # Install specific extras
85
+ pip install ins_pricing[bayesopt] # Model training
86
+ pip install ins_pricing[explain] # Model explanation
87
+ pip install ins_pricing[plotting] # Visualization
88
+ pip install ins_pricing[gnn] # Graph neural networks
89
+ ```
90
+
91
+ #### Multi-platform and GPU notes
92
+
93
+ - Install the correct PyTorch build for your platform/GPU before installing extras.
94
+ - Torch Geometric requires platform-specific wheels; follow the official PyG install guide.
95
+ - Multi-GPU uses torch.distributed/DataParallel where supported; Windows disables CUDA DDP.
96
+
97
+ ---
98
+ ## PyPI Upload (scripts)
99
+
100
+ This repo includes upload scripts for Windows and Linux/macOS.
101
+
102
+ ### Windows
103
+
104
+ ```cmd
105
+ set TWINE_PASSWORD=your_pypi_token_here
106
+ python -m build
107
+ upload_to_pypi.bat
108
+ ```
109
+
110
+ ### Linux / macOS
111
+
112
+ ```bash
113
+ chmod +x upload_to_pypi.sh
114
+ export TWINE_PASSWORD='your_pypi_token_here'
115
+ python -m build
116
+ ./upload_to_pypi.sh
117
+ ```
118
+
119
+ ### Makefile (if make is available)
120
+
121
+ ```bash
122
+ make build
123
+ make upload
124
+ ```
125
+
126
+ ### Tips
127
+
128
+ - Never commit tokens to version control.
129
+ - Use environment variables or secret managers to store credentials.
130
+ - Test with TestPyPI before publishing when needed.
@@ -0,0 +1,92 @@
1
+ # ins_pricing
2
+
3
+ Distribution name: ins_pricing (import package is `ins_pricing`; legacy alias `user_packages` still works).
4
+
5
+ Reusable modelling and pricing utilities organized as a small toolbox with clear boundaries
6
+ between modelling, production, governance, and reporting.
7
+
8
+ ## Architecture
9
+
10
+ - `cli/`: CLI entry points and shared utilities.
11
+ - `modelling/`
12
+ - `bayesopt/`: BayesOpt training core (GLM / XGB / ResNet / FT / GNN).
13
+ - `plotting/`: model-agnostic curves and geo visualizations.
14
+ - `explain/`: permutation, gradients, and SHAP helpers.
15
+ - `evaluation.py`: calibration, metrics, and evaluation utilities.
16
+ - `examples/`: demo configs and notebooks (repo only; not packaged).
17
+ - `pricing/`: factor tables, calibration, exposure, monitoring.
18
+ - `production/`: scoring, metrics, drift/PSI.
19
+ - `governance/`: registry, approval, audit workflows.
20
+ - `reporting/`: report builder and scheduler.
21
+
22
+ ## Call flow (typical)
23
+
24
+ 1. Model training
25
+ - Python API: `from ins_pricing.modelling import BayesOptModel`
26
+ - CLI: `python ins_pricing/cli/BayesOpt_entry.py --config-json ...`
27
+ 2. Evaluation and visualization
28
+ - Curves: `from ins_pricing.plotting import curves`
29
+ - Importance: `from ins_pricing.plotting import importance`
30
+ - Geo: `from ins_pricing.plotting import geo`
31
+ 3. Explainability
32
+ - `from ins_pricing.explain import permutation_importance, integrated_gradients_torch`
33
+ 4. Pricing loop
34
+ - `from ins_pricing.pricing import build_factor_table, rate_premium`
35
+ 5. Production and governance
36
+ - `from ins_pricing.production import batch_score, psi_report`
37
+ - Inference: `from ins_pricing.production import load_predictor_from_config`
38
+ - `from ins_pricing.governance import ModelRegistry, ReleaseManager`
39
+ 6. Reporting
40
+ - `from ins_pricing.reporting import build_report, write_report, schedule_daily`
41
+
42
+ ## Import notes
43
+
44
+ - `ins_pricing` exposes lightweight lazy imports so that pricing/production/governance
45
+ can be used without installing heavy ML dependencies.
46
+ - Demo notebooks/configs live in the repo under `examples/` and are not shipped
47
+ in the PyPI package.
48
+ - Heavy dependencies are only required when you import or use the related modules:
49
+ - BayesOpt: `torch`, `optuna`, `xgboost`, etc.
50
+ - Explain: `torch` (gradients), `shap` (SHAP).
51
+ - Geo plotting on basemap: `contextily`.
52
+ - Plotting: `matplotlib`.
53
+ - Inference: `torch` only when loading FT/ResNet/GNN models.
54
+
55
+ ## Inference interface (new)
56
+
57
+ - `production.inference` provides a small registry-based interface so inference
58
+ does not hard-code model loaders:
59
+ - `ModelSpec` describes the saved model location and config.
60
+ - `PredictorRegistry` lets you plug in custom model loaders.
61
+ - `load_predictor_from_config` remains backward compatible.
62
+
63
+ Example:
64
+
65
+ ```
66
+ from ins_pricing.production import load_predictor_from_config
67
+
68
+ predictor = load_predictor_from_config(
69
+ "config.json",
70
+ "resn",
71
+ device="cuda", # or "mps"/"cpu"
72
+ )
73
+ preds = predictor.predict(df)
74
+ ```
75
+
76
+ ## Multi-platform and GPU notes
77
+
78
+ - Install the correct PyTorch build for your platform/GPU before installing extras.
79
+ - Torch Geometric requires platform-specific wheels; follow the official PyG install guide.
80
+ - Multi-GPU uses DDP or DataParallel where supported; Windows disables CUDA DDP.
81
+ CLI usage prefers `python -m ins_pricing.cli.BayesOpt_entry ...` but the
82
+ direct script path (`python ins_pricing/cli/BayesOpt_entry.py ...`) still works.
83
+
84
+ ## Backward-compatible imports
85
+
86
+ Legacy import paths continue to work:
87
+
88
+ - `import user_packages`
89
+ - `import user_packages.bayesopt`
90
+ - `import user_packages.plotting`
91
+ - `import user_packages.explain`
92
+ - `import user_packages.BayesOpt`
@@ -1,94 +1,146 @@
1
- from __future__ import annotations
2
-
3
- from importlib import import_module
4
- from pathlib import Path
5
- import sys
6
- import types
7
-
8
- _ROOT_SUBPACKAGES = {
9
- "modelling": "ins_pricing.modelling",
10
- "pricing": "ins_pricing.pricing",
11
- "production": "ins_pricing.production",
12
- "governance": "ins_pricing.governance",
13
- "reporting": "ins_pricing.reporting",
14
- }
15
-
16
- _MODELLING_EXPORTS = {
17
- "BayesOptConfig",
18
- "BayesOptModel",
19
- "IOUtils",
20
- "TrainingUtils",
21
- "free_cuda",
22
- }
23
-
1
+ from __future__ import annotations
2
+
3
+ from importlib import import_module
4
+ from pathlib import Path
5
+ import sys
6
+ import types
7
+
8
+ _ROOT_SUBPACKAGES = {
9
+ "modelling": "ins_pricing.modelling",
10
+ "pricing": "ins_pricing.pricing",
11
+ "production": "ins_pricing.production",
12
+ "governance": "ins_pricing.governance",
13
+ "reporting": "ins_pricing.reporting",
14
+ }
15
+
16
+ _MODELLING_EXPORTS = {
17
+ "BayesOptConfig",
18
+ "BayesOptModel",
19
+ }
20
+
21
+ _BAYESOPT_EXPORTS = {
22
+ "BayesOptConfig",
23
+ "DatasetPreprocessor",
24
+ "OutputManager",
25
+ "VersionManager",
26
+ "BayesOptModel",
27
+ "FeatureTokenizer",
28
+ "FTTransformerCore",
29
+ "FTTransformerSklearn",
30
+ "GraphNeuralNetSklearn",
31
+ "MaskedTabularDataset",
32
+ "ResBlock",
33
+ "ResNetSequential",
34
+ "ResNetSklearn",
35
+ "ScaledTransformerEncoderLayer",
36
+ "SimpleGraphLayer",
37
+ "SimpleGNN",
38
+ "TabularDataset",
39
+ "FTTrainer",
40
+ "GLMTrainer",
41
+ "GNNTrainer",
42
+ "ResNetTrainer",
43
+ "TrainerBase",
44
+ "XGBTrainer",
45
+ "_xgb_cuda_available",
46
+ }
47
+
48
+ _LEGACY_EXPORTS = {
49
+ "IOUtils": "ins_pricing.utils",
50
+ "DeviceManager": "ins_pricing.utils",
51
+ "GPUMemoryManager": "ins_pricing.utils",
52
+ "MetricFactory": "ins_pricing.utils",
53
+ "EPS": "ins_pricing.utils",
54
+ "set_global_seed": "ins_pricing.utils",
55
+ "compute_batch_size": "ins_pricing.utils",
56
+ "tweedie_loss": "ins_pricing.utils",
57
+ "infer_factor_and_cate_list": "ins_pricing.utils",
58
+ "DistributedUtils": "ins_pricing.modelling.bayesopt.utils",
59
+ "TrainingUtils": "ins_pricing.modelling.bayesopt.utils",
60
+ "free_cuda": "ins_pricing.modelling.bayesopt.utils",
61
+ "TorchTrainerMixin": "ins_pricing.modelling.bayesopt.utils",
62
+ }
63
+
24
64
  _LAZY_SUBMODULES = {
25
- "bayesopt": "ins_pricing.modelling.core.bayesopt",
65
+ "bayesopt": "ins_pricing.modelling.bayesopt",
26
66
  "plotting": "ins_pricing.modelling.plotting",
27
67
  "explain": "ins_pricing.modelling.explain",
28
- "BayesOpt": "ins_pricing.modelling.core.BayesOpt",
29
- }
30
-
31
- _PACKAGE_PATHS = {
32
- "bayesopt": Path(__file__).resolve().parent / "modelling" / "core" / "bayesopt",
33
- "plotting": Path(__file__).resolve().parent / "modelling" / "plotting",
34
- "explain": Path(__file__).resolve().parent / "modelling" / "explain",
35
68
  }
36
-
37
- __all__ = sorted(
38
- set(_ROOT_SUBPACKAGES)
39
- | set(_MODELLING_EXPORTS)
40
- | set(_LAZY_SUBMODULES)
41
- )
42
-
43
-
44
- def _lazy_module(name: str, target: str, package_path: Path | None = None) -> types.ModuleType:
45
- proxy = types.ModuleType(name)
46
- if package_path is not None:
47
- proxy.__path__ = [str(package_path)]
48
-
49
- def _load():
50
- module = import_module(target)
51
- sys.modules[name] = module
52
- return module
53
-
54
- def __getattr__(attr: str):
55
- module = _load()
56
- return getattr(module, attr)
57
-
58
- def __dir__() -> list[str]:
59
- module = _load()
60
- return sorted(set(dir(module)))
61
-
62
- proxy.__getattr__ = __getattr__ # type: ignore[attr-defined]
63
- proxy.__dir__ = __dir__ # type: ignore[attr-defined]
64
- return proxy
65
-
66
-
67
- def _install_proxy(alias: str, target: str) -> None:
68
- module_name = f"{__name__}.{alias}"
69
- if module_name in sys.modules:
70
- return
71
- proxy = _lazy_module(module_name, target, _PACKAGE_PATHS.get(alias))
72
- sys.modules[module_name] = proxy
73
- globals()[alias] = proxy
74
-
75
-
76
- for _alias, _target in _LAZY_SUBMODULES.items():
77
- _install_proxy(_alias, _target)
78
-
79
-
80
- def __getattr__(name: str):
81
- if name in _ROOT_SUBPACKAGES:
82
- module = import_module(_ROOT_SUBPACKAGES[name])
83
- globals()[name] = module
84
- return module
85
- if name in _MODELLING_EXPORTS:
86
- module = import_module("ins_pricing.modelling")
87
- value = getattr(module, name)
88
- globals()[name] = value
89
- return value
90
- raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
91
-
92
-
93
- def __dir__() -> list[str]:
94
- return sorted(set(__all__) | set(globals().keys()))
69
+
70
+ _PACKAGE_PATHS = {
71
+ "bayesopt": Path(__file__).resolve().parent / "modelling" / "bayesopt",
72
+ "plotting": Path(__file__).resolve().parent / "modelling" / "plotting",
73
+ "explain": Path(__file__).resolve().parent / "modelling" / "explain",
74
+ }
75
+
76
+ __all__ = sorted(
77
+ set(_ROOT_SUBPACKAGES)
78
+ | set(_MODELLING_EXPORTS)
79
+ | set(_BAYESOPT_EXPORTS)
80
+ | set(_LEGACY_EXPORTS)
81
+ | set(_LAZY_SUBMODULES)
82
+ )
83
+
84
+
85
+ def _lazy_module(name: str, target: str, package_path: Path | None = None) -> types.ModuleType:
86
+ proxy = types.ModuleType(name)
87
+ if package_path is not None:
88
+ proxy.__path__ = [str(package_path)]
89
+
90
+ def _load():
91
+ module = import_module(target)
92
+ sys.modules[name] = module
93
+ return module
94
+
95
+ def __getattr__(attr: str):
96
+ module = _load()
97
+ return getattr(module, attr)
98
+
99
+ def __dir__() -> list[str]:
100
+ module = _load()
101
+ return sorted(set(dir(module)))
102
+
103
+ proxy.__getattr__ = __getattr__ # type: ignore[attr-defined]
104
+ proxy.__dir__ = __dir__ # type: ignore[attr-defined]
105
+ return proxy
106
+
107
+
108
+ def _install_proxy(alias: str, target: str) -> None:
109
+ module_name = f"{__name__}.{alias}"
110
+ if module_name in sys.modules:
111
+ return
112
+ proxy = _lazy_module(module_name, target, _PACKAGE_PATHS.get(alias))
113
+ sys.modules[module_name] = proxy
114
+ globals()[alias] = proxy
115
+
116
+
117
+ for _alias, _target in _LAZY_SUBMODULES.items():
118
+ _install_proxy(_alias, _target)
119
+
120
+
121
+ def __getattr__(name: str):
122
+ if name in _ROOT_SUBPACKAGES:
123
+ module = import_module(_ROOT_SUBPACKAGES[name])
124
+ globals()[name] = module
125
+ return module
126
+ if name in _MODELLING_EXPORTS:
127
+ module = import_module("ins_pricing.modelling")
128
+ value = getattr(module, name)
129
+ globals()[name] = value
130
+ return value
131
+ if name in _BAYESOPT_EXPORTS:
132
+ module = import_module("ins_pricing.modelling.bayesopt")
133
+ value = getattr(module, name)
134
+ globals()[name] = value
135
+ return value
136
+ legacy_module = _LEGACY_EXPORTS.get(name)
137
+ if legacy_module:
138
+ module = import_module(legacy_module)
139
+ value = getattr(module, name)
140
+ globals()[name] = value
141
+ return value
142
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
143
+
144
+
145
+ def __dir__() -> list[str]:
146
+ return sorted(set(__all__) | set(globals().keys()))