ins-pricing 0.2.9__tar.gz → 0.3.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.
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/PKG-INFO +162 -149
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/README.md +13 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/CHANGELOG.md +93 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/README.md +11 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/bayesopt_entry_runner.py +626 -499
- ins_pricing-0.3.0/ins_pricing/cli/utils/evaluation_context.py +320 -0
- ins_pricing-0.3.0/ins_pricing/cli/utils/import_resolver.py +350 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/PHASE2_REFACTORING_SUMMARY.md +449 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/PHASE3_REFACTORING_SUMMARY.md +406 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/REFACTORING_SUMMARY.md +247 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/config_components.py +351 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/config_preprocess.py +3 -4
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/core.py +153 -94
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/models/model_ft_trainer.py +118 -31
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/trainers/trainer_base.py +294 -139
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/utils/__init__.py +86 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/utils/constants.py +183 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/utils/distributed_utils.py +186 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/utils/io_utils.py +126 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/utils/metrics_and_devices.py +540 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/utils/torch_trainer_mixin.py +587 -0
- ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/utils.py +105 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/setup.py +1 -1
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing.egg-info/PKG-INFO +162 -149
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing.egg-info/SOURCES.txt +13 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/pyproject.toml +1 -1
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/setup.cfg +4 -4
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/MANIFEST.in +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/RELEASE_NOTES_0.2.8.md +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/BayesOpt_entry.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/BayesOpt_incremental.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/Explain_Run.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/Explain_entry.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/Pricing_Run.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/utils/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/utils/cli_common.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/utils/cli_config.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/utils/notebook_utils.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/utils/run_logging.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/cli/watchdog_run.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/docs/modelling/BayesOpt_USAGE.md +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/docs/modelling/README.md +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/exceptions.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/governance/README.md +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/governance/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/governance/approval.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/governance/audit.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/governance/registry.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/governance/release.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/BayesOpt.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/model_explain_mixin.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/model_plotting_mixin.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/models/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/models/model_ft_components.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/models/model_gnn.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/models/model_resn.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/trainers/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/trainers/trainer_ft.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/trainers/trainer_glm.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/trainers/trainer_gnn.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/trainers/trainer_resn.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/bayesopt/trainers/trainer_xgb.py +0 -0
- /ins_pricing-0.2.9/ins_pricing/modelling/core/bayesopt/utils.py → /ins_pricing-0.3.0/ins_pricing/modelling/core/bayesopt/utils_backup.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/core/evaluation.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/explain/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/explain/gradients.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/explain/metrics.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/explain/permutation.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/explain/shap_utils.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/plotting/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/plotting/common.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/plotting/curves.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/plotting/diagnostics.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/plotting/geo.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/modelling/plotting/importance.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/pricing/README.md +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/pricing/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/pricing/calibration.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/pricing/data_quality.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/pricing/exposure.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/pricing/factors.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/pricing/monitoring.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/pricing/rate_table.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/production/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/production/drift.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/production/monitoring.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/production/predict.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/production/preprocess.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/production/scoring.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/reporting/README.md +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/reporting/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/reporting/report_builder.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/reporting/scheduler.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/governance/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/governance/test_audit.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/governance/test_registry.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/governance/test_release.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/conftest.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/test_cross_val_generic.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/test_distributed_utils.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/test_explain.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/test_geo_tokens_split.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/test_graph_cache.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/test_plotting.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/test_plotting_library.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/modelling/test_preprocessor.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/pricing/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/pricing/test_calibration.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/pricing/test_exposure.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/pricing/test_factors.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/pricing/test_rate_table.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/production/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/production/test_monitoring.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/production/test_predict.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/production/test_preprocess.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/tests/production/test_scoring.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/utils/__init__.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/utils/device.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/utils/logging.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/utils/metrics.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/utils/paths.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/utils/profiling.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing/utils/validation.py +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing.egg-info/dependency_links.txt +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing.egg-info/requires.txt +0 -0
- {ins_pricing-0.2.9 → ins_pricing-0.3.0}/ins_pricing.egg-info/top_level.txt +0 -0
|
@@ -1,149 +1,162 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ins_pricing
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Reusable modelling, pricing, governance, and reporting utilities.
|
|
5
|
-
Author: meishi125478
|
|
6
|
-
License: Proprietary
|
|
7
|
-
Keywords: pricing,insurance,bayesopt,ml
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
-
Classifier: License :: Other/Proprietary License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Classifier: Intended Audience :: Developers
|
|
14
|
-
Requires-Python: >=3.9
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
Requires-Dist: numpy>=1.20
|
|
17
|
-
Requires-Dist: pandas>=1.4
|
|
18
|
-
Provides-Extra: bayesopt
|
|
19
|
-
Requires-Dist: torch>=1.13; extra == "bayesopt"
|
|
20
|
-
Requires-Dist: optuna>=3.0; extra == "bayesopt"
|
|
21
|
-
Requires-Dist: xgboost>=1.6; extra == "bayesopt"
|
|
22
|
-
Requires-Dist: scikit-learn>=1.1; extra == "bayesopt"
|
|
23
|
-
Requires-Dist: statsmodels>=0.13; extra == "bayesopt"
|
|
24
|
-
Requires-Dist: joblib>=1.2; extra == "bayesopt"
|
|
25
|
-
Requires-Dist: matplotlib>=3.5; extra == "bayesopt"
|
|
26
|
-
Provides-Extra: plotting
|
|
27
|
-
Requires-Dist: matplotlib>=3.5; extra == "plotting"
|
|
28
|
-
Requires-Dist: scikit-learn>=1.1; extra == "plotting"
|
|
29
|
-
Provides-Extra: explain
|
|
30
|
-
Requires-Dist: torch>=1.13; extra == "explain"
|
|
31
|
-
Requires-Dist: shap>=0.41; extra == "explain"
|
|
32
|
-
Requires-Dist: scikit-learn>=1.1; extra == "explain"
|
|
33
|
-
Provides-Extra: geo
|
|
34
|
-
Requires-Dist: contextily>=1.3; extra == "geo"
|
|
35
|
-
Requires-Dist: matplotlib>=3.5; extra == "geo"
|
|
36
|
-
Provides-Extra: gnn
|
|
37
|
-
Requires-Dist: torch>=1.13; extra == "gnn"
|
|
38
|
-
Requires-Dist: pynndescent>=0.5; extra == "gnn"
|
|
39
|
-
Requires-Dist: torch-geometric>=2.3; extra == "gnn"
|
|
40
|
-
Provides-Extra: all
|
|
41
|
-
Requires-Dist: torch>=1.13; extra == "all"
|
|
42
|
-
Requires-Dist: optuna>=3.0; extra == "all"
|
|
43
|
-
Requires-Dist: xgboost>=1.6; extra == "all"
|
|
44
|
-
Requires-Dist: scikit-learn>=1.1; extra == "all"
|
|
45
|
-
Requires-Dist: statsmodels>=0.13; extra == "all"
|
|
46
|
-
Requires-Dist: joblib>=1.2; extra == "all"
|
|
47
|
-
Requires-Dist: matplotlib>=3.5; extra == "all"
|
|
48
|
-
Requires-Dist: shap>=0.41; extra == "all"
|
|
49
|
-
Requires-Dist: contextily>=1.3; extra == "all"
|
|
50
|
-
Requires-Dist: pynndescent>=0.5; extra == "all"
|
|
51
|
-
Requires-Dist: torch-geometric>=2.3; extra == "all"
|
|
52
|
-
|
|
53
|
-
# Insurance-Pricing
|
|
54
|
-
|
|
55
|
-
A reusable toolkit for insurance modeling, pricing, governance, and reporting.
|
|
56
|
-
|
|
57
|
-
## Overview
|
|
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.
|
|
60
|
-
|
|
61
|
-
### Core Modules
|
|
62
|
-
|
|
63
|
-
| Module | Description |
|
|
64
|
-
|--------|-------------|
|
|
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 |
|
|
71
|
-
|
|
72
|
-
### Quick Start
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
# Model training with Bayesian optimization
|
|
76
|
-
from ins_pricing import bayesopt as ropt
|
|
77
|
-
|
|
78
|
-
model = ropt.BayesOptModel(
|
|
79
|
-
train_data, test_data,
|
|
80
|
-
model_name='my_model',
|
|
81
|
-
resp_nme='target',
|
|
82
|
-
weight_nme='weight',
|
|
83
|
-
factor_nmes=feature_list,
|
|
84
|
-
cate_list=categorical_features,
|
|
85
|
-
)
|
|
86
|
-
model.bayesopt_xgb(max_evals=100) # Train XGBoost
|
|
87
|
-
model.bayesopt_resnet(max_evals=50) # Train ResNet
|
|
88
|
-
model.bayesopt_ft(max_evals=50) # Train FT-Transformer
|
|
89
|
-
|
|
90
|
-
# Pricing: build factor table
|
|
91
|
-
from ins_pricing.pricing import build_factor_table
|
|
92
|
-
factors = build_factor_table(
|
|
93
|
-
df,
|
|
94
|
-
factor_col='age_band',
|
|
95
|
-
loss_col='claim_amount',
|
|
96
|
-
exposure_col='exposure',
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
# Production: batch scoring
|
|
100
|
-
from ins_pricing.production import batch_score
|
|
101
|
-
scores = batch_score(model.trainers['xgb'].predict, df)
|
|
102
|
-
|
|
103
|
-
# Model governance
|
|
104
|
-
from ins_pricing.governance import ModelRegistry
|
|
105
|
-
registry = ModelRegistry('models.json')
|
|
106
|
-
registry.register(model_name, version, metrics=metrics)
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Project Structure
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
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
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Installation
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
# Basic installation
|
|
130
|
-
pip install ins_pricing
|
|
131
|
-
|
|
132
|
-
# Full installation (all optional dependencies)
|
|
133
|
-
pip install ins_pricing[all]
|
|
134
|
-
|
|
135
|
-
# Install specific extras
|
|
136
|
-
pip install ins_pricing[bayesopt] # Model training
|
|
137
|
-
pip install ins_pricing[explain] # Model explanation
|
|
138
|
-
pip install ins_pricing[plotting] # Visualization
|
|
139
|
-
pip install ins_pricing[gnn] # Graph neural networks
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ins_pricing
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Reusable modelling, pricing, governance, and reporting utilities.
|
|
5
|
+
Author: meishi125478
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Keywords: pricing,insurance,bayesopt,ml
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: License :: Other/Proprietary License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: numpy>=1.20
|
|
17
|
+
Requires-Dist: pandas>=1.4
|
|
18
|
+
Provides-Extra: bayesopt
|
|
19
|
+
Requires-Dist: torch>=1.13; extra == "bayesopt"
|
|
20
|
+
Requires-Dist: optuna>=3.0; extra == "bayesopt"
|
|
21
|
+
Requires-Dist: xgboost>=1.6; extra == "bayesopt"
|
|
22
|
+
Requires-Dist: scikit-learn>=1.1; extra == "bayesopt"
|
|
23
|
+
Requires-Dist: statsmodels>=0.13; extra == "bayesopt"
|
|
24
|
+
Requires-Dist: joblib>=1.2; extra == "bayesopt"
|
|
25
|
+
Requires-Dist: matplotlib>=3.5; extra == "bayesopt"
|
|
26
|
+
Provides-Extra: plotting
|
|
27
|
+
Requires-Dist: matplotlib>=3.5; extra == "plotting"
|
|
28
|
+
Requires-Dist: scikit-learn>=1.1; extra == "plotting"
|
|
29
|
+
Provides-Extra: explain
|
|
30
|
+
Requires-Dist: torch>=1.13; extra == "explain"
|
|
31
|
+
Requires-Dist: shap>=0.41; extra == "explain"
|
|
32
|
+
Requires-Dist: scikit-learn>=1.1; extra == "explain"
|
|
33
|
+
Provides-Extra: geo
|
|
34
|
+
Requires-Dist: contextily>=1.3; extra == "geo"
|
|
35
|
+
Requires-Dist: matplotlib>=3.5; extra == "geo"
|
|
36
|
+
Provides-Extra: gnn
|
|
37
|
+
Requires-Dist: torch>=1.13; extra == "gnn"
|
|
38
|
+
Requires-Dist: pynndescent>=0.5; extra == "gnn"
|
|
39
|
+
Requires-Dist: torch-geometric>=2.3; extra == "gnn"
|
|
40
|
+
Provides-Extra: all
|
|
41
|
+
Requires-Dist: torch>=1.13; extra == "all"
|
|
42
|
+
Requires-Dist: optuna>=3.0; extra == "all"
|
|
43
|
+
Requires-Dist: xgboost>=1.6; extra == "all"
|
|
44
|
+
Requires-Dist: scikit-learn>=1.1; extra == "all"
|
|
45
|
+
Requires-Dist: statsmodels>=0.13; extra == "all"
|
|
46
|
+
Requires-Dist: joblib>=1.2; extra == "all"
|
|
47
|
+
Requires-Dist: matplotlib>=3.5; extra == "all"
|
|
48
|
+
Requires-Dist: shap>=0.41; extra == "all"
|
|
49
|
+
Requires-Dist: contextily>=1.3; extra == "all"
|
|
50
|
+
Requires-Dist: pynndescent>=0.5; extra == "all"
|
|
51
|
+
Requires-Dist: torch-geometric>=2.3; extra == "all"
|
|
52
|
+
|
|
53
|
+
# Insurance-Pricing
|
|
54
|
+
|
|
55
|
+
A reusable toolkit for insurance modeling, pricing, governance, and reporting.
|
|
56
|
+
|
|
57
|
+
## Overview
|
|
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.
|
|
60
|
+
|
|
61
|
+
### Core Modules
|
|
62
|
+
|
|
63
|
+
| Module | Description |
|
|
64
|
+
|--------|-------------|
|
|
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 |
|
|
71
|
+
|
|
72
|
+
### Quick Start
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
# Model training with Bayesian optimization
|
|
76
|
+
from ins_pricing import bayesopt as ropt
|
|
77
|
+
|
|
78
|
+
model = ropt.BayesOptModel(
|
|
79
|
+
train_data, test_data,
|
|
80
|
+
model_name='my_model',
|
|
81
|
+
resp_nme='target',
|
|
82
|
+
weight_nme='weight',
|
|
83
|
+
factor_nmes=feature_list,
|
|
84
|
+
cate_list=categorical_features,
|
|
85
|
+
)
|
|
86
|
+
model.bayesopt_xgb(max_evals=100) # Train XGBoost
|
|
87
|
+
model.bayesopt_resnet(max_evals=50) # Train ResNet
|
|
88
|
+
model.bayesopt_ft(max_evals=50) # Train FT-Transformer
|
|
89
|
+
|
|
90
|
+
# Pricing: build factor table
|
|
91
|
+
from ins_pricing.pricing import build_factor_table
|
|
92
|
+
factors = build_factor_table(
|
|
93
|
+
df,
|
|
94
|
+
factor_col='age_band',
|
|
95
|
+
loss_col='claim_amount',
|
|
96
|
+
exposure_col='exposure',
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Production: batch scoring
|
|
100
|
+
from ins_pricing.production import batch_score
|
|
101
|
+
scores = batch_score(model.trainers['xgb'].predict, df)
|
|
102
|
+
|
|
103
|
+
# Model governance
|
|
104
|
+
from ins_pricing.governance import ModelRegistry
|
|
105
|
+
registry = ModelRegistry('models.json')
|
|
106
|
+
registry.register(model_name, version, metrics=metrics)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Project Structure
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
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
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Installation
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Basic installation
|
|
130
|
+
pip install ins_pricing
|
|
131
|
+
|
|
132
|
+
# Full installation (all optional dependencies)
|
|
133
|
+
pip install ins_pricing[all]
|
|
134
|
+
|
|
135
|
+
# Install specific extras
|
|
136
|
+
pip install ins_pricing[bayesopt] # Model training
|
|
137
|
+
pip install ins_pricing[explain] # Model explanation
|
|
138
|
+
pip install ins_pricing[plotting] # Visualization
|
|
139
|
+
pip install ins_pricing[gnn] # Graph neural networks
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### Multi-platform & GPU installation notes
|
|
143
|
+
|
|
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.
|
|
154
|
+
|
|
155
|
+
### Requirements
|
|
156
|
+
|
|
157
|
+
- Python >= 3.9
|
|
158
|
+
- Core dependencies: numpy >= 1.20, pandas >= 1.4
|
|
159
|
+
|
|
160
|
+
### License
|
|
161
|
+
|
|
162
|
+
Proprietary
|
|
@@ -87,6 +87,19 @@ pip install ins_pricing[plotting] # Visualization
|
|
|
87
87
|
pip install ins_pricing[gnn] # Graph neural networks
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
+
#### Multi-platform & GPU installation notes
|
|
91
|
+
|
|
92
|
+
- **PyTorch (CPU/GPU/MPS)**: Install the correct PyTorch build for your platform/GPU first (CUDA on
|
|
93
|
+
Linux/Windows, ROCm on supported AMD platforms, or MPS on Apple Silicon). Then install the
|
|
94
|
+
optional extras you need (e.g., `bayesopt`, `explain`, or `gnn`). This avoids pip pulling a
|
|
95
|
+
mismatched wheel.
|
|
96
|
+
- **Torch Geometric (GNN)**: `torch-geometric` often requires platform-specific wheels (e.g.,
|
|
97
|
+
`torch-scatter`, `torch-sparse`). Follow the official PyG installation instructions for your
|
|
98
|
+
CUDA/ROCm/CPU environment, then install `ins_pricing[gnn]`.
|
|
99
|
+
- **Multi-GPU**: Training code will use CUDA when available and can enable multi-GPU via
|
|
100
|
+
`torch.distributed`/`DataParallel` where supported. On Windows, CUDA DDP is not supported and will
|
|
101
|
+
fall back to single-GPU or DataParallel where possible.
|
|
102
|
+
|
|
90
103
|
### Requirements
|
|
91
104
|
|
|
92
105
|
- Python >= 3.9
|
|
@@ -5,6 +5,99 @@ All notable changes to the ins_pricing project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.11] - 2026-01-15
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
#### Refactoring Phase 3: Utils Module Consolidation
|
|
13
|
+
- **Eliminated code duplication** - Consolidated duplicated utility classes:
|
|
14
|
+
- `DeviceManager` and `GPUMemoryManager` now imported from `ins_pricing.utils`
|
|
15
|
+
- Removed 181 lines of duplicate code from `bayesopt/utils/metrics_and_devices.py`
|
|
16
|
+
- File size reduced from 721 to 540 lines (25% reduction)
|
|
17
|
+
- **Benefit**: Single source of truth for device management utilities
|
|
18
|
+
- **Impact**: Bug fixes now propagate automatically, no risk of code drift
|
|
19
|
+
- **Compatibility**: 100% backward compatible - all import patterns continue working
|
|
20
|
+
|
|
21
|
+
**Technical Details**:
|
|
22
|
+
- Package-level `ins_pricing/utils/device.py` is now the canonical implementation
|
|
23
|
+
- BayesOpt utils automatically re-export these classes for backward compatibility
|
|
24
|
+
- No breaking changes required in existing code
|
|
25
|
+
|
|
26
|
+
## [0.2.10] - 2026-01-15
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
#### Refactoring Phase 2: Simplified BayesOptModel API
|
|
31
|
+
- **BayesOptModel config-based initialization** - New recommended API using configuration objects:
|
|
32
|
+
- Added `config` parameter accepting `BayesOptConfig` instances
|
|
33
|
+
- **Before**: 56 individual parameters required
|
|
34
|
+
- **After**: Single config object parameter
|
|
35
|
+
- **Benefits**: Improved code clarity, reusability, type safety, and testability
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
#### API Improvements
|
|
40
|
+
- **BayesOptModel initialization** - Enhanced parameter handling:
|
|
41
|
+
- New API: `BayesOptModel(train_df, test_df, config=BayesOptConfig(...))`
|
|
42
|
+
- Old API still supported with deprecation warning
|
|
43
|
+
- Made `model_nme`, `resp_nme`, `weight_nme` optional (validated when config=None)
|
|
44
|
+
- Added type validation for config parameter
|
|
45
|
+
- Added helpful error messages for missing required parameters
|
|
46
|
+
|
|
47
|
+
### Deprecated
|
|
48
|
+
|
|
49
|
+
- **BayesOptModel individual parameters** - Passing 56 individual parameters to `__init__`:
|
|
50
|
+
- Use `config=BayesOptConfig(...)` instead
|
|
51
|
+
- Old API will be removed in v0.4.0
|
|
52
|
+
- Migration guide: See `modelling/core/bayesopt/PHASE2_REFACTORING_SUMMARY.md`
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- **Type hints** - Improved type safety in BayesOptModel initialization
|
|
57
|
+
- **Documentation** - Added comprehensive examples of both old and new APIs
|
|
58
|
+
|
|
59
|
+
## [0.2.9] - 2026-01-15
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
|
|
63
|
+
#### Refactoring Phase 1: Utils Module Split
|
|
64
|
+
- **Modular utils package** - Split monolithic 1,503-line utils.py into focused modules:
|
|
65
|
+
- `utils/constants.py` (183 lines) - Core constants and simple helpers
|
|
66
|
+
- `utils/io_utils.py` (110 lines) - File I/O and parameter loading
|
|
67
|
+
- `utils/distributed_utils.py` (163 lines) - DDP and CUDA management
|
|
68
|
+
- `utils/torch_trainer_mixin.py` (587 lines) - PyTorch training infrastructure
|
|
69
|
+
- `utils/metrics_and_devices.py` (721 lines) - Metrics, GPU, device, CV, plotting
|
|
70
|
+
- `utils/__init__.py` (86 lines) - Backward compatibility re-exports
|
|
71
|
+
|
|
72
|
+
- **Upload automation** - Cross-platform PyPI upload scripts:
|
|
73
|
+
- `upload_to_pypi.sh` - Shell script for Linux/macOS with auto-version extraction
|
|
74
|
+
- `upload_to_pypi.bat` - Updated Windows batch script with auto-version extraction
|
|
75
|
+
- `Makefile` - Cross-platform build automation (build, check, upload, clean)
|
|
76
|
+
- `README_UPLOAD.md` - Comprehensive upload documentation in English
|
|
77
|
+
- `UPLOAD_QUICK_START.md` - Quick start guide for package publishing
|
|
78
|
+
|
|
79
|
+
### Changed
|
|
80
|
+
|
|
81
|
+
#### Code Organization
|
|
82
|
+
- **utils module structure** - Improved maintainability and testability:
|
|
83
|
+
- Average file size reduced from 1,503 to 351 lines per module
|
|
84
|
+
- Each module has single responsibility
|
|
85
|
+
- Independent testing now possible for each component
|
|
86
|
+
- **Impact**: 100% backward compatibility maintained via re-exports
|
|
87
|
+
|
|
88
|
+
### Deprecated
|
|
89
|
+
|
|
90
|
+
- **utils.py single file import** - Direct import from `bayesopt/utils.py`:
|
|
91
|
+
- Use `from .utils import ...` instead (package import)
|
|
92
|
+
- Old single-file import shows deprecation warning
|
|
93
|
+
- File will be removed in v0.4.0
|
|
94
|
+
- **Note**: All imports continue to work identically
|
|
95
|
+
|
|
96
|
+
### Removed
|
|
97
|
+
|
|
98
|
+
- **verify_core_decoupling.py** - Obsolete test script for unimplemented refactoring
|
|
99
|
+
- Cleanup logged in `.cleanup_log.md`
|
|
100
|
+
|
|
8
101
|
## [0.2.8] - 2026-01-14
|
|
9
102
|
|
|
10
103
|
### Added
|
|
@@ -52,6 +52,17 @@ between modelling, production, governance, and reporting.
|
|
|
52
52
|
- Geo plotting on basemap: `contextily`.
|
|
53
53
|
- Plotting: `matplotlib`.
|
|
54
54
|
|
|
55
|
+
## Multi-platform & GPU installation notes
|
|
56
|
+
|
|
57
|
+
- **Install PyTorch first**: Use the correct PyTorch build for your platform/GPU (CUDA/ROCm/MPS)
|
|
58
|
+
before installing the `bayesopt`, `explain`, or `gnn` extras. This avoids incompatible wheels.
|
|
59
|
+
- **GNN dependencies**: `torch-geometric` and its companion packages are platform-specific. Follow
|
|
60
|
+
the official PyG install guide for your CUDA/ROCm/CPU environment, then install
|
|
61
|
+
`ins_pricing[gnn]`.
|
|
62
|
+
- **Multi-GPU**: Training utilities will select CUDA/MPS/CPU automatically. Multi-GPU uses DDP or
|
|
63
|
+
DataParallel when supported; on Windows, CUDA DDP is disabled and will fall back to single-GPU or
|
|
64
|
+
DataParallel where available.
|
|
65
|
+
|
|
55
66
|
## Backward-compatible imports
|
|
56
67
|
|
|
57
68
|
Legacy import paths continue to work:
|