ins-pricing 0.4.4__py3-none-any.whl → 0.4.5__py3-none-any.whl
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/README.md +66 -74
- ins_pricing/cli/BayesOpt_incremental.py +904 -904
- ins_pricing/cli/bayesopt_entry_runner.py +1442 -1442
- ins_pricing/frontend/README.md +573 -419
- ins_pricing/frontend/config_builder.py +1 -0
- ins_pricing/modelling/README.md +67 -0
- ins_pricing/modelling/core/bayesopt/README.md +59 -0
- ins_pricing/modelling/core/bayesopt/config_preprocess.py +12 -0
- ins_pricing/modelling/core/bayesopt/core.py +3 -1
- ins_pricing/setup.py +1 -1
- {ins_pricing-0.4.4.dist-info → ins_pricing-0.4.5.dist-info}/METADATA +182 -162
- {ins_pricing-0.4.4.dist-info → ins_pricing-0.4.5.dist-info}/RECORD +14 -21
- ins_pricing/CHANGELOG.md +0 -272
- ins_pricing/RELEASE_NOTES_0.2.8.md +0 -344
- ins_pricing/docs/LOSS_FUNCTIONS.md +0 -78
- ins_pricing/docs/modelling/BayesOpt_USAGE.md +0 -945
- ins_pricing/docs/modelling/README.md +0 -34
- ins_pricing/frontend/QUICKSTART.md +0 -152
- ins_pricing/modelling/core/bayesopt/PHASE2_REFACTORING_SUMMARY.md +0 -449
- ins_pricing/modelling/core/bayesopt/PHASE3_REFACTORING_SUMMARY.md +0 -406
- ins_pricing/modelling/core/bayesopt/REFACTORING_SUMMARY.md +0 -247
- {ins_pricing-0.4.4.dist-info → ins_pricing-0.4.5.dist-info}/WHEEL +0 -0
- {ins_pricing-0.4.4.dist-info → ins_pricing-0.4.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Modelling
|
|
2
|
+
|
|
3
|
+
This directory contains reusable training tooling and frameworks centered on BayesOpt.
|
|
4
|
+
|
|
5
|
+
## Key locations
|
|
6
|
+
|
|
7
|
+
- `core/bayesopt/` - core training/tuning package
|
|
8
|
+
- `explain/` - explainability helpers
|
|
9
|
+
- `plotting/` - plotting utilities
|
|
10
|
+
- `ins_pricing/cli/` - CLI entry points
|
|
11
|
+
- `examples/` - example configs and notebooks (repo only)
|
|
12
|
+
|
|
13
|
+
## Common usage
|
|
14
|
+
|
|
15
|
+
- CLI training: `python ins_pricing/cli/BayesOpt_entry.py --config-json config_template.json`
|
|
16
|
+
- Notebook API: `from ins_pricing.modelling import BayesOptModel`
|
|
17
|
+
|
|
18
|
+
## Explainability
|
|
19
|
+
|
|
20
|
+
- CLI: `python ins_pricing/cli/Explain_entry.py --config-json config_explain_template.json`
|
|
21
|
+
- Notebook: `examples/04 Explain_Run.ipynb`
|
|
22
|
+
|
|
23
|
+
## Loss functions
|
|
24
|
+
|
|
25
|
+
Configure the regression/classification loss with `loss_name` in the BayesOpt config.
|
|
26
|
+
|
|
27
|
+
Supported `loss_name` values:
|
|
28
|
+
- `auto` (default): legacy behavior based on model name
|
|
29
|
+
- `tweedie`: Tweedie deviance
|
|
30
|
+
- `poisson`: Poisson deviance
|
|
31
|
+
- `gamma`: Gamma deviance
|
|
32
|
+
- `mse`: mean squared error
|
|
33
|
+
- `mae`: mean absolute error
|
|
34
|
+
|
|
35
|
+
Mapping summary:
|
|
36
|
+
- Tweedie deviance -> `tweedie`
|
|
37
|
+
- Poisson deviance -> `poisson`
|
|
38
|
+
- Gamma deviance -> `gamma`
|
|
39
|
+
- Mean squared error -> `mse`
|
|
40
|
+
- Mean absolute error -> `mae`
|
|
41
|
+
- Classification log loss -> `logloss` (classification only)
|
|
42
|
+
- Classification BCE -> `bce` (classification only)
|
|
43
|
+
|
|
44
|
+
Classification tasks:
|
|
45
|
+
- `loss_name` can be `auto`, `logloss`, or `bce`.
|
|
46
|
+
- Training uses `BCEWithLogits` for torch models; evaluation uses log loss.
|
|
47
|
+
|
|
48
|
+
Where to set `loss_name`:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"task_type": "regression",
|
|
53
|
+
"loss_name": "mse"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Behavior notes:
|
|
58
|
+
- When `loss_name` is `mse` or `mae`, tuning does not sample Tweedie power.
|
|
59
|
+
- When `loss_name` is `poisson` or `gamma`, power is fixed (1.0 / 2.0).
|
|
60
|
+
- When `loss_name` is `tweedie`, power is sampled as usual.
|
|
61
|
+
- XGBoost objective is selected from the loss name.
|
|
62
|
+
|
|
63
|
+
## Notes
|
|
64
|
+
|
|
65
|
+
- Models load from `output_dir/model` by default (override with `explain.model_dir`).
|
|
66
|
+
- Training outputs are written to `plot/`, `Results/`, and `model/` under `output_dir`.
|
|
67
|
+
- Keep large data and secrets outside the repo; use environment variables or `.env` files.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# BayesOpt
|
|
2
|
+
|
|
3
|
+
BayesOpt is the training/tuning core for GLM, XGBoost, ResNet, FT-Transformer, and GNN workflows.
|
|
4
|
+
It supports JSON-driven CLI runs and a Python API for notebooks/scripts.
|
|
5
|
+
|
|
6
|
+
## Recommended API (config-based)
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
from ins_pricing.modelling.core.bayesopt import BayesOptConfig
|
|
10
|
+
from ins_pricing.modelling import BayesOptModel
|
|
11
|
+
|
|
12
|
+
config = BayesOptConfig(
|
|
13
|
+
model_nme="my_model",
|
|
14
|
+
resp_nme="target",
|
|
15
|
+
weight_nme="weight",
|
|
16
|
+
factor_nmes=["f1", "f2"],
|
|
17
|
+
cate_list=["f2"],
|
|
18
|
+
task_type="regression",
|
|
19
|
+
epochs=50,
|
|
20
|
+
output_dir="./Results",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
model = BayesOptModel(train_data, test_data, config=config)
|
|
24
|
+
model.optimize_model("xgb", max_evals=50)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Load config from file
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from ins_pricing.modelling.core.bayesopt import BayesOptConfig
|
|
31
|
+
from ins_pricing.modelling import BayesOptModel
|
|
32
|
+
|
|
33
|
+
config = BayesOptConfig.from_file("config.json")
|
|
34
|
+
model = BayesOptModel(train_data, test_data, config=config)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## CLI entry
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
python ins_pricing/cli/BayesOpt_entry.py --config-json config_template.json
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## FT roles
|
|
44
|
+
|
|
45
|
+
- `model`: FT is a prediction model (writes `pred_ft`).
|
|
46
|
+
- `embedding`: FT trains with labels but exports embeddings (`pred_<prefix>_*`).
|
|
47
|
+
- `unsupervised_embedding`: FT trains without labels and exports embeddings.
|
|
48
|
+
|
|
49
|
+
## Output layout
|
|
50
|
+
|
|
51
|
+
`output_dir/` contains:
|
|
52
|
+
- `plot/` plots and diagnostics
|
|
53
|
+
- `Results/` metrics, params, and snapshots
|
|
54
|
+
- `model/` saved models
|
|
55
|
+
|
|
56
|
+
## Notes
|
|
57
|
+
|
|
58
|
+
- Relative paths in config are resolved from the config file directory.
|
|
59
|
+
- For multi-GPU, use `torchrun` and set `runner.nproc_per_node` in config.
|
|
@@ -97,6 +97,7 @@ class BayesOptConfig:
|
|
|
97
97
|
use_gnn_ddp: Use DDP for GNN
|
|
98
98
|
ft_role: FT-Transformer role ('model', 'embedding', 'unsupervised_embedding')
|
|
99
99
|
cv_strategy: CV strategy ('random', 'group', 'time', 'stratified')
|
|
100
|
+
build_oht: Whether to build one-hot encoded features (default True)
|
|
100
101
|
|
|
101
102
|
Example:
|
|
102
103
|
>>> config = BayesOptConfig(
|
|
@@ -192,6 +193,7 @@ class BayesOptConfig:
|
|
|
192
193
|
preprocess_artifact_path: Optional[str] = None
|
|
193
194
|
plot_path_style: str = "nested"
|
|
194
195
|
bo_sample_limit: Optional[int] = None
|
|
196
|
+
build_oht: bool = True
|
|
195
197
|
cache_predictions: bool = False
|
|
196
198
|
prediction_cache_dir: Optional[str] = None
|
|
197
199
|
prediction_cache_format: str = "parquet"
|
|
@@ -465,6 +467,16 @@ class DatasetPreprocessor:
|
|
|
465
467
|
self.num_features = [
|
|
466
468
|
nme for nme in cfg.factor_nmes if nme not in cate_list]
|
|
467
469
|
|
|
470
|
+
build_oht = bool(getattr(cfg, "build_oht", True))
|
|
471
|
+
if not build_oht:
|
|
472
|
+
print("[Preprocess] build_oht=False; skip one-hot features.", flush=True)
|
|
473
|
+
self.train_oht_data = None
|
|
474
|
+
self.test_oht_data = None
|
|
475
|
+
self.train_oht_scl_data = None
|
|
476
|
+
self.test_oht_scl_data = None
|
|
477
|
+
self.var_nmes = list(cfg.factor_nmes)
|
|
478
|
+
return self
|
|
479
|
+
|
|
468
480
|
# Memory optimization: Single copy + in-place operations
|
|
469
481
|
train_oht = self.train_data[cfg.factor_nmes +
|
|
470
482
|
[cfg.weight_nme] + [cfg.resp_nme]].copy()
|
|
@@ -201,6 +201,8 @@ class BayesOptModel(BayesOptPlottingMixin, BayesOptExplainMixin):
|
|
|
201
201
|
raise ValueError("weight_nme is required when not using config parameter")
|
|
202
202
|
|
|
203
203
|
# Infer categorical features if needed
|
|
204
|
+
# Only use user-specified categorical list for one-hot; do not auto-infer.
|
|
205
|
+
user_cate_list = [] if cate_list is None else list(cate_list)
|
|
204
206
|
inferred_factors, inferred_cats = infer_factor_and_cate_list(
|
|
205
207
|
train_df=train_data,
|
|
206
208
|
test_df=test_data,
|
|
@@ -208,7 +210,7 @@ class BayesOptModel(BayesOptPlottingMixin, BayesOptExplainMixin):
|
|
|
208
210
|
weight_nme=weight_nme,
|
|
209
211
|
binary_resp_nme=binary_resp_nme,
|
|
210
212
|
factor_nmes=factor_nmes,
|
|
211
|
-
cate_list=
|
|
213
|
+
cate_list=user_cate_list,
|
|
212
214
|
infer_categorical_max_unique=int(infer_categorical_max_unique),
|
|
213
215
|
infer_categorical_max_ratio=float(infer_categorical_max_ratio),
|
|
214
216
|
)
|
ins_pricing/setup.py
CHANGED
|
@@ -1,162 +1,182 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ins_pricing
|
|
3
|
-
Version: 0.4.
|
|
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
|
|
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
|
-
model.
|
|
88
|
-
model.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
registry
|
|
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
|
-
pip install ins_pricing[
|
|
138
|
-
pip install ins_pricing[
|
|
139
|
-
pip install ins_pricing[
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ins_pricing
|
|
3
|
+
Version: 0.4.5
|
|
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
|
|
60
|
+
model training, pricing calculations, and model governance workflows in the insurance industry.
|
|
61
|
+
|
|
62
|
+
### Core Modules
|
|
63
|
+
|
|
64
|
+
| Module | Description |
|
|
65
|
+
|--------|-------------|
|
|
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 |
|
|
72
|
+
|
|
73
|
+
### Quick Start
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
# Model training with Bayesian optimization
|
|
77
|
+
from ins_pricing import bayesopt as ropt
|
|
78
|
+
|
|
79
|
+
model = ropt.BayesOptModel(
|
|
80
|
+
train_data, test_data,
|
|
81
|
+
model_name='my_model',
|
|
82
|
+
resp_nme='target',
|
|
83
|
+
weight_nme='weight',
|
|
84
|
+
factor_nmes=feature_list,
|
|
85
|
+
cate_list=categorical_features,
|
|
86
|
+
)
|
|
87
|
+
model.bayesopt_xgb(max_evals=100) # Train XGBoost
|
|
88
|
+
model.bayesopt_resnet(max_evals=50) # Train ResNet
|
|
89
|
+
model.bayesopt_ft(max_evals=50) # Train FT-Transformer
|
|
90
|
+
|
|
91
|
+
# Pricing: build factor table
|
|
92
|
+
from ins_pricing.pricing import build_factor_table
|
|
93
|
+
factors = build_factor_table(
|
|
94
|
+
df,
|
|
95
|
+
factor_col='age_band',
|
|
96
|
+
loss_col='claim_amount',
|
|
97
|
+
exposure_col='exposure',
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Production: batch scoring
|
|
101
|
+
from ins_pricing.production import batch_score
|
|
102
|
+
scores = batch_score(model.trainers['xgb'].predict, df)
|
|
103
|
+
|
|
104
|
+
# Model governance
|
|
105
|
+
from ins_pricing.governance import ModelRegistry
|
|
106
|
+
registry = ModelRegistry('models.json')
|
|
107
|
+
registry.register(model_name, version, metrics=metrics)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Project Structure
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
ins_pricing/
|
|
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
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Installation
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Basic installation
|
|
131
|
+
pip install ins_pricing
|
|
132
|
+
|
|
133
|
+
# Full installation (all optional dependencies)
|
|
134
|
+
pip install ins_pricing[all]
|
|
135
|
+
|
|
136
|
+
# Install specific extras
|
|
137
|
+
pip install ins_pricing[bayesopt] # Model training
|
|
138
|
+
pip install ins_pricing[explain] # Model explanation
|
|
139
|
+
pip install ins_pricing[plotting] # Visualization
|
|
140
|
+
pip install ins_pricing[gnn] # Graph neural networks
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Multi-platform and GPU notes
|
|
144
|
+
|
|
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.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
## PyPI Upload (scripts)
|
|
151
|
+
|
|
152
|
+
This repo includes upload scripts for Windows and Linux/macOS.
|
|
153
|
+
|
|
154
|
+
### Windows
|
|
155
|
+
|
|
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.
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
ins_pricing/
|
|
2
|
-
ins_pricing/README.md,sha256=W4V2xtzM6pyQzwJPvWP7cNn-We9rxM8xrxRlBVQwoY8,3399
|
|
3
|
-
ins_pricing/RELEASE_NOTES_0.2.8.md,sha256=KIJzk1jbZbZPKjwnkPSDHO_2Ipv3SP3CzCNDdf07jI0,9331
|
|
1
|
+
ins_pricing/README.md,sha256=lmT3UhGMxWtM_FCmg8elQZIgaFTEhoZYTTv_Iq26eJY,2770
|
|
4
2
|
ins_pricing/__init__.py,sha256=46j1wCdLVrgrofeBwKl-3NXTxzjbTv-w3KjW-dyKGiY,2622
|
|
5
3
|
ins_pricing/exceptions.py,sha256=5fZavPV4zNJ7wPC75L215KkHXX9pRrfDAYZOdSKJMGo,4778
|
|
6
|
-
ins_pricing/setup.py,sha256=
|
|
4
|
+
ins_pricing/setup.py,sha256=gAnzDOPPzmun2x7Is9inR5MX7XE7_bHJc9VIQqGmMNo,1702
|
|
7
5
|
ins_pricing/cli/BayesOpt_entry.py,sha256=6UBVxu36O3bXn1WC-BBi-l_W9_MqEoHmDGnwwDKNo5Q,1594
|
|
8
|
-
ins_pricing/cli/BayesOpt_incremental.py,sha256=
|
|
6
|
+
ins_pricing/cli/BayesOpt_incremental.py,sha256=WR2DJSVsCfUvR6_0xc-2vss85CB4m0bIiB_xjRRxqSE,36809
|
|
9
7
|
ins_pricing/cli/Explain_Run.py,sha256=gEPQjqHiXyXlCTKjUzwSvbAn5_h74ABgb_sEGs-YHVE,664
|
|
10
8
|
ins_pricing/cli/Explain_entry.py,sha256=xS23x31qRvXqy2Wvo21wbkxmPRLHy77aZbtjY-J59NA,23570
|
|
11
9
|
ins_pricing/cli/Pricing_Run.py,sha256=qZribQ_ku4NK4oIvlrLJdM-jyyKtIUoCbbvo8Wh_RQ4,711
|
|
12
10
|
ins_pricing/cli/__init__.py,sha256=F296f1J_tBPv33lDJQ6LaN_CPwMJTMtOuTsMof0dr2o,50
|
|
13
|
-
ins_pricing/cli/bayesopt_entry_runner.py,sha256=
|
|
11
|
+
ins_pricing/cli/bayesopt_entry_runner.py,sha256=JERCqHcS50lcA1dIP8RiA-7xsjfIQD8ZXWLyUAq5Nqk,55261
|
|
14
12
|
ins_pricing/cli/watchdog_run.py,sha256=ehUkN9VqsQkxc6YC_WLanU6Pu-ers-nvPEtCaJ9UsgY,6188
|
|
15
13
|
ins_pricing/cli/utils/__init__.py,sha256=u3kt1B27OiuOEgw6PQN-fNs9vNiAjdPyybsRQsZkM_I,54
|
|
16
14
|
ins_pricing/cli/utils/cli_common.py,sha256=CgMnN_0NQQt7Bh5RjClOydz0LzU2TBmIOsFa3KxYQOQ,8254
|
|
@@ -19,14 +17,10 @@ ins_pricing/cli/utils/evaluation_context.py,sha256=0zuDOcVzkWiuj4HyAT0psaAfEbSqp
|
|
|
19
17
|
ins_pricing/cli/utils/import_resolver.py,sha256=Ut-SBN4F2sw8O7B3GveMoZn4__1IGwljvxC4sLU0tpk,12531
|
|
20
18
|
ins_pricing/cli/utils/notebook_utils.py,sha256=xjSjn6z4_x2vfX1SV4X_VG0jXdK1KJzWJ5tJ4CHFxy0,12037
|
|
21
19
|
ins_pricing/cli/utils/run_logging.py,sha256=V3Wh2EV6c1Mo0QTvfe4hl2J4LOR6bdQsT210o__YBWk,3677
|
|
22
|
-
ins_pricing/
|
|
23
|
-
ins_pricing/docs/modelling/BayesOpt_USAGE.md,sha256=O5A50RT-drWsEhKIooqWJPfTNN1AwB0166MLli0vMvw,40593
|
|
24
|
-
ins_pricing/docs/modelling/README.md,sha256=2a7m1dBnacxBKjEV9k16Qj9IPstlwwuis1QxdsMrFmA,1976
|
|
25
|
-
ins_pricing/frontend/QUICKSTART.md,sha256=uS5RuuICXt8J7BjPruoGOoAnTBjzgaNpwqemmUqZrZ4,4488
|
|
26
|
-
ins_pricing/frontend/README.md,sha256=Dlo4QghAWkawIK_x2P-0hu2Sv2yZTFkduOPxVLe_1qs,12524
|
|
20
|
+
ins_pricing/frontend/README.md,sha256=MKQuVtwpvrOKBJhcz9wgVtMc-jKERYATRNDIj-hA78Y,17551
|
|
27
21
|
ins_pricing/frontend/__init__.py,sha256=KeL6QbUGAzWKbjGyZi_u7p289Zv5yslRCNZ6wHWY63Q,335
|
|
28
22
|
ins_pricing/frontend/app.py,sha256=DBrnewX5RUjuJXGEezihZJcDnp-tEeA-fCuTeqAFEqU,38484
|
|
29
|
-
ins_pricing/frontend/config_builder.py,sha256=
|
|
23
|
+
ins_pricing/frontend/config_builder.py,sha256=GNeEe7-Xt-WLakKlbdbQOE82ogWWwEFaKQ5LxxZeLFc,12261
|
|
30
24
|
ins_pricing/frontend/example_config.json,sha256=aDXH9_5bVlIclwMWH5WfgK572LVuraNbj4565o3d71k,741
|
|
31
25
|
ins_pricing/frontend/example_workflows.py,sha256=7iuFOIhN6l__3AVDkhDU7zvi2oWx_Z9lktpATPM336s,36813
|
|
32
26
|
ins_pricing/frontend/ft_workflow.py,sha256=CWrviErHEjZ2NPibIbPh69AYKPVkn-mXY7uncPihn-0,11206
|
|
@@ -37,17 +31,16 @@ ins_pricing/governance/approval.py,sha256=cjJQjU1ziR-d-9wVSXyMyX6S5zijJqDWERZNxj
|
|
|
37
31
|
ins_pricing/governance/audit.py,sha256=f0aw-LaOxH5NGzxwczeLrGMJcxO-JDRn99BpI55KRn4,1040
|
|
38
32
|
ins_pricing/governance/registry.py,sha256=2uxQL6qMGY5IYWJti9MpaV_auvL--piJaasFrX20ghk,3139
|
|
39
33
|
ins_pricing/governance/release.py,sha256=ltyFIdeKbwj9fnEDxcQCURaQ5Zc_j0mqXFPNunmX_NQ,4743
|
|
34
|
+
ins_pricing/modelling/README.md,sha256=4q3CykeFcXo5FILGD2EtoX2yYVV0EbrYW-hwgcySBN0,2157
|
|
40
35
|
ins_pricing/modelling/__init__.py,sha256=0tiXRE3rAwSxHT0dSaosWf_vGd7FpRA_kHW6dclr4PA,2710
|
|
41
36
|
ins_pricing/modelling/core/BayesOpt.py,sha256=i2tB3c6EeucjKAsHyicGDNU7DVVCTihg-TgSoM1y18E,3332
|
|
42
37
|
ins_pricing/modelling/core/__init__.py,sha256=bF5OWfK_mfg5P2oz2jid3MGi9uA13fpqKK-DbPkuci0,54
|
|
43
38
|
ins_pricing/modelling/core/evaluation.py,sha256=wEMWdzs12vPnDo5t183ORMDA6APuc5g6g9Uyfd6GVi8,3905
|
|
44
|
-
ins_pricing/modelling/core/bayesopt/
|
|
45
|
-
ins_pricing/modelling/core/bayesopt/PHASE3_REFACTORING_SUMMARY.md,sha256=B8ZEzaLesU454OaR10Tg50es7t30UB9pxF6GabbNbj0,11804
|
|
46
|
-
ins_pricing/modelling/core/bayesopt/REFACTORING_SUMMARY.md,sha256=hJZKXe9-bBGJVN_5c5l8nHQ1X7NK4BbeE-uXQoH0rAM,7479
|
|
39
|
+
ins_pricing/modelling/core/bayesopt/README.md,sha256=vNTYu5Jk425-RpyVZg_W4PRPWBy6pULYlQHks1a0S2Y,1625
|
|
47
40
|
ins_pricing/modelling/core/bayesopt/__init__.py,sha256=nj6IA0r7D5U5-hYyiwXmcp_bEtoU-hRJ_prdtRmLMg0,2070
|
|
48
41
|
ins_pricing/modelling/core/bayesopt/config_components.py,sha256=OjRyM1EuSXL9_3THD1nGLRsioJs7lO_ZKVZDkUA3LX8,12156
|
|
49
|
-
ins_pricing/modelling/core/bayesopt/config_preprocess.py,sha256=
|
|
50
|
-
ins_pricing/modelling/core/bayesopt/core.py,sha256=
|
|
42
|
+
ins_pricing/modelling/core/bayesopt/config_preprocess.py,sha256=lAsdvLr-H7ajkyRElcKvAQn4ZWEOqkpDqb6ZBsdesfc,22157
|
|
43
|
+
ins_pricing/modelling/core/bayesopt/core.py,sha256=RvnP3yIy-FOQUFdONVfJQxnI7hhNbPTKNQaqhtXd928,44640
|
|
51
44
|
ins_pricing/modelling/core/bayesopt/model_explain_mixin.py,sha256=jCk1zPpwgwBBCndaq-A0_cQnc4RHueh2p5cAuE9ArTo,11620
|
|
52
45
|
ins_pricing/modelling/core/bayesopt/model_plotting_mixin.py,sha256=lD0rUvWV4eWatmTzMrmAUm2Flj8uAOa3R9S2JyYV94k,21807
|
|
53
46
|
ins_pricing/modelling/core/bayesopt/utils.py,sha256=fTDqBHCxsOVte0QhPqnMw8vkefIvkppufIRkt9iHqjU,2852
|
|
@@ -131,7 +124,7 @@ ins_pricing/utils/paths.py,sha256=o_tBiclFvBci4cYg9WANwKPxrMcglEdOjDP-EZgGjdQ,87
|
|
|
131
124
|
ins_pricing/utils/profiling.py,sha256=kmbykHLcYywlZxAf_aVU8HXID3zOvUcBoO5Q58AijhA,11132
|
|
132
125
|
ins_pricing/utils/torch_compat.py,sha256=UrRsqx2qboDG8WE0OmxNOi08ojwE-dCxTQh0N2s3Rgw,2441
|
|
133
126
|
ins_pricing/utils/validation.py,sha256=4Tw9VUJPk0N-WO3YUqZP-xXRl1Xpubkm0vi3WzzZrv4,13348
|
|
134
|
-
ins_pricing-0.4.
|
|
135
|
-
ins_pricing-0.4.
|
|
136
|
-
ins_pricing-0.4.
|
|
137
|
-
ins_pricing-0.4.
|
|
127
|
+
ins_pricing-0.4.5.dist-info/METADATA,sha256=hPEBGaROhj_R7RTIT0fc4J5oeVaImalZYp8DNSC0rG8,5891
|
|
128
|
+
ins_pricing-0.4.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
129
|
+
ins_pricing-0.4.5.dist-info/top_level.txt,sha256=haZuNQpHKNBEPZx3NjLnHp8pV3I_J9QG8-HyJn00FA0,12
|
|
130
|
+
ins_pricing-0.4.5.dist-info/RECORD,,
|