ins-pricing 0.5.0__tar.gz → 0.5.1__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.5.0 → ins_pricing-0.5.1}/PKG-INFO +182 -182
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/BayesOpt_entry.py +15 -5
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/BayesOpt_incremental.py +43 -10
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/Explain_Run.py +16 -5
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/Explain_entry.py +29 -8
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/Pricing_Run.py +16 -5
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/bayesopt_entry_runner.py +45 -12
- ins_pricing-0.5.1/ins_pricing/cli/utils/bootstrap.py +23 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/utils/cli_config.py +34 -15
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/utils/import_resolver.py +14 -14
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/utils/notebook_utils.py +120 -106
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/watchdog_run.py +15 -5
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/frontend/app.py +132 -61
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/frontend/config_builder.py +33 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/frontend/example_config.json +11 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/frontend/runner.py +340 -388
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/README.md +1 -1
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/README.md +29 -11
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/config_components.py +12 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/config_preprocess.py +50 -13
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/core.py +47 -19
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/model_plotting_mixin.py +20 -14
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/models/model_ft_components.py +349 -342
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/models/model_ft_trainer.py +11 -5
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/models/model_gnn.py +20 -14
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/models/model_resn.py +9 -3
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/trainers/trainer_base.py +62 -50
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/trainers/trainer_ft.py +61 -53
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/trainers/trainer_glm.py +9 -3
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/trainers/trainer_gnn.py +40 -32
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/trainers/trainer_resn.py +36 -24
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/trainers/trainer_xgb.py +240 -37
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/utils/distributed_utils.py +193 -186
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/utils/torch_trainer_mixin.py +23 -10
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/pricing/factors.py +67 -56
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/setup.py +1 -1
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/__init__.py +7 -6
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/device.py +45 -24
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/logging.py +34 -1
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/profiling.py +8 -4
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing.egg-info/PKG-INFO +182 -182
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing.egg-info/SOURCES.txt +1 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/pyproject.toml +1 -1
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/setup.cfg +4 -4
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/MANIFEST.in +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/README.md +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/README.md +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/utils/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/utils/cli_common.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/utils/evaluation_context.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/cli/utils/run_logging.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/exceptions.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/frontend/README.md +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/frontend/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/frontend/example_workflows.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/frontend/ft_workflow.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/governance/README.md +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/governance/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/governance/approval.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/governance/audit.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/governance/registry.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/governance/release.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/model_explain_mixin.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/models/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/trainers/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/utils/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/utils/constants.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/utils/io_utils.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/utils/losses.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/bayesopt/utils/metrics_and_devices.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/evaluation.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/explain/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/explain/gradients.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/explain/metrics.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/explain/permutation.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/explain/shap_utils.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/plotting/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/plotting/common.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/plotting/compat.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/plotting/curves.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/plotting/diagnostics.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/plotting/geo.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/modelling/plotting/importance.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/pricing/README.md +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/pricing/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/pricing/calibration.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/pricing/data_quality.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/pricing/exposure.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/pricing/monitoring.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/pricing/rate_table.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/production/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/production/drift.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/production/inference.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/production/monitoring.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/production/preprocess.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/production/scoring.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/reporting/README.md +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/reporting/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/reporting/report_builder.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/reporting/scheduler.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/governance/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/governance/test_audit.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/governance/test_registry.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/governance/test_release.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/conftest.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/test_cross_val_generic.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/test_distributed_utils.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/test_explain.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/test_geo_tokens_split.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/test_graph_cache.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/test_plotting.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/test_plotting_library.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/modelling/test_preprocessor.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/pricing/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/pricing/test_calibration.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/pricing/test_exposure.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/pricing/test_factors.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/pricing/test_rate_table.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/production/__init__.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/production/test_inference.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/production/test_monitoring.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/production/test_preprocess.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/tests/production/test_scoring.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/features.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/io.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/losses.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/metrics.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/numerics.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/paths.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/torch_compat.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing/utils/validation.py +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing.egg-info/dependency_links.txt +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing.egg-info/requires.txt +0 -0
- {ins_pricing-0.5.0 → ins_pricing-0.5.1}/ins_pricing.egg-info/top_level.txt +0 -0
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ins_pricing
|
|
3
|
-
Version: 0.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
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ins_pricing
|
|
3
|
+
Version: 0.5.1
|
|
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.
|
|
@@ -11,11 +11,21 @@ import json
|
|
|
11
11
|
import os
|
|
12
12
|
import sys
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
if
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
def _ensure_repo_root() -> None:
|
|
15
|
+
if __package__ not in {None, ""}:
|
|
16
|
+
return
|
|
17
|
+
if importlib.util.find_spec("ins_pricing") is not None:
|
|
18
|
+
return
|
|
19
|
+
bootstrap_path = Path(__file__).resolve().parents[1] / "utils" / "bootstrap.py"
|
|
20
|
+
spec = importlib.util.spec_from_file_location("ins_pricing.cli.utils.bootstrap", bootstrap_path)
|
|
21
|
+
if spec is None or spec.loader is None:
|
|
22
|
+
return
|
|
23
|
+
module = importlib.util.module_from_spec(spec)
|
|
24
|
+
spec.loader.exec_module(module)
|
|
25
|
+
module.ensure_repo_root()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_ensure_repo_root()
|
|
19
29
|
|
|
20
30
|
def _apply_env_from_config(argv: list[str]) -> None:
|
|
21
31
|
if "--config-json" not in argv:
|
|
@@ -20,11 +20,22 @@ from pathlib import Path
|
|
|
20
20
|
import importlib.util
|
|
21
21
|
import sys
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
|
|
24
|
+
def _ensure_repo_root() -> None:
|
|
25
|
+
if __package__ not in {None, ""}:
|
|
26
|
+
return
|
|
27
|
+
if importlib.util.find_spec("ins_pricing") is not None:
|
|
28
|
+
return
|
|
29
|
+
bootstrap_path = Path(__file__).resolve().parents[1] / "utils" / "bootstrap.py"
|
|
30
|
+
spec = importlib.util.spec_from_file_location("ins_pricing.cli.utils.bootstrap", bootstrap_path)
|
|
31
|
+
if spec is None or spec.loader is None:
|
|
32
|
+
return
|
|
33
|
+
module = importlib.util.module_from_spec(spec)
|
|
34
|
+
spec.loader.exec_module(module)
|
|
35
|
+
module.ensure_repo_root()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
_ensure_repo_root()
|
|
28
39
|
|
|
29
40
|
import argparse
|
|
30
41
|
import json
|
|
@@ -422,9 +433,20 @@ class IncrementalUpdateRunner:
|
|
|
422
433
|
self.prediction_cache_dir = runtime_cfg["prediction_cache_dir"]
|
|
423
434
|
self.prediction_cache_format = runtime_cfg["prediction_cache_format"]
|
|
424
435
|
self.plot_path_style = runtime_cfg["plot_path_style"]
|
|
425
|
-
self.xgb_max_depth_max = runtime_cfg["xgb_max_depth_max"]
|
|
426
|
-
self.xgb_n_estimators_max = runtime_cfg["xgb_n_estimators_max"]
|
|
427
|
-
self.
|
|
436
|
+
self.xgb_max_depth_max = runtime_cfg["xgb_max_depth_max"]
|
|
437
|
+
self.xgb_n_estimators_max = runtime_cfg["xgb_n_estimators_max"]
|
|
438
|
+
self.xgb_gpu_id = runtime_cfg["xgb_gpu_id"]
|
|
439
|
+
self.xgb_cleanup_per_fold = runtime_cfg["xgb_cleanup_per_fold"]
|
|
440
|
+
self.xgb_cleanup_synchronize = runtime_cfg["xgb_cleanup_synchronize"]
|
|
441
|
+
self.xgb_use_dmatrix = runtime_cfg["xgb_use_dmatrix"]
|
|
442
|
+
self.ft_cleanup_per_fold = runtime_cfg["ft_cleanup_per_fold"]
|
|
443
|
+
self.ft_cleanup_synchronize = runtime_cfg["ft_cleanup_synchronize"]
|
|
444
|
+
self.resn_cleanup_per_fold = runtime_cfg["resn_cleanup_per_fold"]
|
|
445
|
+
self.resn_cleanup_synchronize = runtime_cfg["resn_cleanup_synchronize"]
|
|
446
|
+
self.gnn_cleanup_per_fold = runtime_cfg["gnn_cleanup_per_fold"]
|
|
447
|
+
self.gnn_cleanup_synchronize = runtime_cfg["gnn_cleanup_synchronize"]
|
|
448
|
+
self.optuna_cleanup_synchronize = runtime_cfg["optuna_cleanup_synchronize"]
|
|
449
|
+
self.optuna_storage = runtime_cfg["optuna_storage"]
|
|
428
450
|
self.optuna_study_prefix = runtime_cfg["optuna_study_prefix"]
|
|
429
451
|
self.best_params_files = runtime_cfg["best_params_files"]
|
|
430
452
|
self.reuse_best_params = runtime_cfg["reuse_best_params"]
|
|
@@ -593,8 +615,19 @@ class IncrementalUpdateRunner:
|
|
|
593
615
|
use_ft_ddp=self.cfg.get("use_ft_ddp", False),
|
|
594
616
|
use_gnn_ddp=self.cfg.get("use_gnn_ddp", False),
|
|
595
617
|
output_dir=str(self.output_root) if self.output_root else None,
|
|
596
|
-
xgb_max_depth_max=self.xgb_max_depth_max,
|
|
597
|
-
xgb_n_estimators_max=self.xgb_n_estimators_max,
|
|
618
|
+
xgb_max_depth_max=self.xgb_max_depth_max,
|
|
619
|
+
xgb_n_estimators_max=self.xgb_n_estimators_max,
|
|
620
|
+
xgb_gpu_id=self.xgb_gpu_id,
|
|
621
|
+
xgb_cleanup_per_fold=self.xgb_cleanup_per_fold,
|
|
622
|
+
xgb_cleanup_synchronize=self.xgb_cleanup_synchronize,
|
|
623
|
+
xgb_use_dmatrix=self.xgb_use_dmatrix,
|
|
624
|
+
ft_cleanup_per_fold=self.ft_cleanup_per_fold,
|
|
625
|
+
ft_cleanup_synchronize=self.ft_cleanup_synchronize,
|
|
626
|
+
resn_cleanup_per_fold=self.resn_cleanup_per_fold,
|
|
627
|
+
resn_cleanup_synchronize=self.resn_cleanup_synchronize,
|
|
628
|
+
gnn_cleanup_per_fold=self.gnn_cleanup_per_fold,
|
|
629
|
+
gnn_cleanup_synchronize=self.gnn_cleanup_synchronize,
|
|
630
|
+
optuna_cleanup_synchronize=self.optuna_cleanup_synchronize,
|
|
598
631
|
resn_weight_decay=self.cfg.get("resn_weight_decay"),
|
|
599
632
|
final_ensemble=bool(self.cfg.get("final_ensemble", False)),
|
|
600
633
|
final_ensemble_k=int(self.cfg.get("final_ensemble_k", 3)),
|
|
@@ -5,11 +5,22 @@ from typing import Optional
|
|
|
5
5
|
import importlib.util
|
|
6
6
|
import sys
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
|
|
9
|
+
def _ensure_repo_root() -> None:
|
|
10
|
+
if __package__ not in {None, ""}:
|
|
11
|
+
return
|
|
12
|
+
if importlib.util.find_spec("ins_pricing") is not None:
|
|
13
|
+
return
|
|
14
|
+
bootstrap_path = Path(__file__).resolve().parents[1] / "utils" / "bootstrap.py"
|
|
15
|
+
spec = importlib.util.spec_from_file_location("ins_pricing.cli.utils.bootstrap", bootstrap_path)
|
|
16
|
+
if spec is None or spec.loader is None:
|
|
17
|
+
return
|
|
18
|
+
module = importlib.util.module_from_spec(spec)
|
|
19
|
+
spec.loader.exec_module(module)
|
|
20
|
+
module.ensure_repo_root()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_ensure_repo_root()
|
|
13
24
|
|
|
14
25
|
try:
|
|
15
26
|
from ins_pricing.cli.utils.notebook_utils import run_from_config, run_from_config_cli # type: ignore
|
|
@@ -6,11 +6,21 @@ from pathlib import Path
|
|
|
6
6
|
import importlib.util
|
|
7
7
|
import sys
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
if
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
def _ensure_repo_root() -> None:
|
|
10
|
+
if __package__ not in {None, ""}:
|
|
11
|
+
return
|
|
12
|
+
if importlib.util.find_spec("ins_pricing") is not None:
|
|
13
|
+
return
|
|
14
|
+
bootstrap_path = Path(__file__).resolve().parents[1] / "utils" / "bootstrap.py"
|
|
15
|
+
spec = importlib.util.spec_from_file_location("ins_pricing.cli.utils.bootstrap", bootstrap_path)
|
|
16
|
+
if spec is None or spec.loader is None:
|
|
17
|
+
return
|
|
18
|
+
module = importlib.util.module_from_spec(spec)
|
|
19
|
+
spec.loader.exec_module(module)
|
|
20
|
+
module.ensure_repo_root()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_ensure_repo_root()
|
|
14
24
|
|
|
15
25
|
import argparse
|
|
16
26
|
import json
|
|
@@ -460,9 +470,20 @@ def explain_from_config(args: argparse.Namespace) -> None:
|
|
|
460
470
|
"epochs": int(runtime_cfg["epochs"]),
|
|
461
471
|
"use_gpu": bool(cfg.get("use_gpu", True)),
|
|
462
472
|
"output_dir": output_dir,
|
|
463
|
-
"xgb_max_depth_max": runtime_cfg["xgb_max_depth_max"],
|
|
464
|
-
"xgb_n_estimators_max": runtime_cfg["xgb_n_estimators_max"],
|
|
465
|
-
"
|
|
473
|
+
"xgb_max_depth_max": runtime_cfg["xgb_max_depth_max"],
|
|
474
|
+
"xgb_n_estimators_max": runtime_cfg["xgb_n_estimators_max"],
|
|
475
|
+
"xgb_gpu_id": runtime_cfg["xgb_gpu_id"],
|
|
476
|
+
"xgb_cleanup_per_fold": runtime_cfg["xgb_cleanup_per_fold"],
|
|
477
|
+
"xgb_cleanup_synchronize": runtime_cfg["xgb_cleanup_synchronize"],
|
|
478
|
+
"xgb_use_dmatrix": runtime_cfg["xgb_use_dmatrix"],
|
|
479
|
+
"ft_cleanup_per_fold": runtime_cfg["ft_cleanup_per_fold"],
|
|
480
|
+
"ft_cleanup_synchronize": runtime_cfg["ft_cleanup_synchronize"],
|
|
481
|
+
"resn_cleanup_per_fold": runtime_cfg["resn_cleanup_per_fold"],
|
|
482
|
+
"resn_cleanup_synchronize": runtime_cfg["resn_cleanup_synchronize"],
|
|
483
|
+
"gnn_cleanup_per_fold": runtime_cfg["gnn_cleanup_per_fold"],
|
|
484
|
+
"gnn_cleanup_synchronize": runtime_cfg["gnn_cleanup_synchronize"],
|
|
485
|
+
"optuna_cleanup_synchronize": runtime_cfg["optuna_cleanup_synchronize"],
|
|
486
|
+
"resn_weight_decay": cfg.get("resn_weight_decay"),
|
|
466
487
|
"final_ensemble": bool(cfg.get("final_ensemble", False)),
|
|
467
488
|
"final_ensemble_k": int(cfg.get("final_ensemble_k", 3)),
|
|
468
489
|
"final_refit": bool(cfg.get("final_refit", True)),
|
|
@@ -5,11 +5,22 @@ from typing import Optional
|
|
|
5
5
|
import importlib.util
|
|
6
6
|
import sys
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
|
|
9
|
+
def _ensure_repo_root() -> None:
|
|
10
|
+
if __package__ not in {None, ""}:
|
|
11
|
+
return
|
|
12
|
+
if importlib.util.find_spec("ins_pricing") is not None:
|
|
13
|
+
return
|
|
14
|
+
bootstrap_path = Path(__file__).resolve().parents[1] / "utils" / "bootstrap.py"
|
|
15
|
+
spec = importlib.util.spec_from_file_location("ins_pricing.cli.utils.bootstrap", bootstrap_path)
|
|
16
|
+
if spec is None or spec.loader is None:
|
|
17
|
+
return
|
|
18
|
+
module = importlib.util.module_from_spec(spec)
|
|
19
|
+
spec.loader.exec_module(module)
|
|
20
|
+
module.ensure_repo_root()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_ensure_repo_root()
|
|
13
24
|
|
|
14
25
|
try:
|
|
15
26
|
from ins_pricing.cli.utils.notebook_utils import run_from_config, run_from_config_cli # type: ignore
|
|
@@ -15,11 +15,22 @@ from pathlib import Path
|
|
|
15
15
|
import importlib.util
|
|
16
16
|
import sys
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
|
|
19
|
+
def _ensure_repo_root() -> None:
|
|
20
|
+
if __package__ not in {None, ""}:
|
|
21
|
+
return
|
|
22
|
+
if importlib.util.find_spec("ins_pricing") is not None:
|
|
23
|
+
return
|
|
24
|
+
bootstrap_path = Path(__file__).resolve().parents[1] / "utils" / "bootstrap.py"
|
|
25
|
+
spec = importlib.util.spec_from_file_location("ins_pricing.cli.utils.bootstrap", bootstrap_path)
|
|
26
|
+
if spec is None or spec.loader is None:
|
|
27
|
+
return
|
|
28
|
+
module = importlib.util.module_from_spec(spec)
|
|
29
|
+
spec.loader.exec_module(module)
|
|
30
|
+
module.ensure_repo_root()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
_ensure_repo_root()
|
|
23
34
|
|
|
24
35
|
import argparse
|
|
25
36
|
import hashlib
|
|
@@ -1114,10 +1125,21 @@ def train_from_config(args: argparse.Namespace) -> None:
|
|
|
1114
1125
|
output_override=args.output_dir,
|
|
1115
1126
|
)
|
|
1116
1127
|
output_dir = output_cfg["output_dir"]
|
|
1117
|
-
reuse_best_params = bool(
|
|
1118
|
-
args.reuse_best_params or runtime_cfg["reuse_best_params"])
|
|
1119
|
-
xgb_max_depth_max = runtime_cfg["xgb_max_depth_max"]
|
|
1120
|
-
xgb_n_estimators_max = runtime_cfg["xgb_n_estimators_max"]
|
|
1128
|
+
reuse_best_params = bool(
|
|
1129
|
+
args.reuse_best_params or runtime_cfg["reuse_best_params"])
|
|
1130
|
+
xgb_max_depth_max = runtime_cfg["xgb_max_depth_max"]
|
|
1131
|
+
xgb_n_estimators_max = runtime_cfg["xgb_n_estimators_max"]
|
|
1132
|
+
xgb_gpu_id = runtime_cfg["xgb_gpu_id"]
|
|
1133
|
+
xgb_cleanup_per_fold = runtime_cfg["xgb_cleanup_per_fold"]
|
|
1134
|
+
xgb_cleanup_synchronize = runtime_cfg["xgb_cleanup_synchronize"]
|
|
1135
|
+
xgb_use_dmatrix = runtime_cfg["xgb_use_dmatrix"]
|
|
1136
|
+
ft_cleanup_per_fold = runtime_cfg["ft_cleanup_per_fold"]
|
|
1137
|
+
ft_cleanup_synchronize = runtime_cfg["ft_cleanup_synchronize"]
|
|
1138
|
+
resn_cleanup_per_fold = runtime_cfg["resn_cleanup_per_fold"]
|
|
1139
|
+
resn_cleanup_synchronize = runtime_cfg["resn_cleanup_synchronize"]
|
|
1140
|
+
gnn_cleanup_per_fold = runtime_cfg["gnn_cleanup_per_fold"]
|
|
1141
|
+
gnn_cleanup_synchronize = runtime_cfg["gnn_cleanup_synchronize"]
|
|
1142
|
+
optuna_cleanup_synchronize = runtime_cfg["optuna_cleanup_synchronize"]
|
|
1121
1143
|
optuna_storage = runtime_cfg["optuna_storage"]
|
|
1122
1144
|
optuna_study_prefix = runtime_cfg["optuna_study_prefix"]
|
|
1123
1145
|
best_params_files = runtime_cfg["best_params_files"]
|
|
@@ -1249,9 +1271,20 @@ def train_from_config(args: argparse.Namespace) -> None:
|
|
|
1249
1271
|
"use_ft_ddp": use_ft_ddp,
|
|
1250
1272
|
"use_gnn_ddp": use_gnn_ddp,
|
|
1251
1273
|
"output_dir": output_dir,
|
|
1252
|
-
"xgb_max_depth_max": xgb_max_depth_max,
|
|
1253
|
-
"xgb_n_estimators_max": xgb_n_estimators_max,
|
|
1254
|
-
"
|
|
1274
|
+
"xgb_max_depth_max": xgb_max_depth_max,
|
|
1275
|
+
"xgb_n_estimators_max": xgb_n_estimators_max,
|
|
1276
|
+
"xgb_gpu_id": xgb_gpu_id,
|
|
1277
|
+
"xgb_cleanup_per_fold": xgb_cleanup_per_fold,
|
|
1278
|
+
"xgb_cleanup_synchronize": xgb_cleanup_synchronize,
|
|
1279
|
+
"xgb_use_dmatrix": xgb_use_dmatrix,
|
|
1280
|
+
"ft_cleanup_per_fold": ft_cleanup_per_fold,
|
|
1281
|
+
"ft_cleanup_synchronize": ft_cleanup_synchronize,
|
|
1282
|
+
"resn_cleanup_per_fold": resn_cleanup_per_fold,
|
|
1283
|
+
"resn_cleanup_synchronize": resn_cleanup_synchronize,
|
|
1284
|
+
"gnn_cleanup_per_fold": gnn_cleanup_per_fold,
|
|
1285
|
+
"gnn_cleanup_synchronize": gnn_cleanup_synchronize,
|
|
1286
|
+
"optuna_cleanup_synchronize": optuna_cleanup_synchronize,
|
|
1287
|
+
"resn_weight_decay": cfg.get("resn_weight_decay"),
|
|
1255
1288
|
"final_ensemble": bool(cfg.get("final_ensemble", False)),
|
|
1256
1289
|
"final_ensemble_k": int(cfg.get("final_ensemble_k", 3)),
|
|
1257
1290
|
"final_refit": bool(cfg.get("final_refit", True)),
|