ins-pricing 0.4.5__py3-none-any.whl → 0.5.1__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 +48 -22
- ins_pricing/__init__.py +142 -90
- ins_pricing/cli/BayesOpt_entry.py +58 -46
- ins_pricing/cli/BayesOpt_incremental.py +77 -110
- ins_pricing/cli/Explain_Run.py +42 -23
- ins_pricing/cli/Explain_entry.py +551 -577
- ins_pricing/cli/Pricing_Run.py +42 -23
- ins_pricing/cli/bayesopt_entry_runner.py +51 -16
- ins_pricing/cli/utils/bootstrap.py +23 -0
- ins_pricing/cli/utils/cli_common.py +256 -256
- ins_pricing/cli/utils/cli_config.py +379 -360
- ins_pricing/cli/utils/import_resolver.py +375 -358
- ins_pricing/cli/utils/notebook_utils.py +256 -242
- ins_pricing/cli/watchdog_run.py +216 -198
- ins_pricing/frontend/__init__.py +10 -10
- ins_pricing/frontend/app.py +132 -61
- ins_pricing/frontend/config_builder.py +33 -0
- ins_pricing/frontend/example_config.json +11 -0
- ins_pricing/frontend/example_workflows.py +1 -1
- ins_pricing/frontend/runner.py +340 -388
- ins_pricing/governance/__init__.py +20 -20
- ins_pricing/governance/release.py +159 -159
- ins_pricing/modelling/README.md +1 -1
- ins_pricing/modelling/__init__.py +147 -92
- ins_pricing/modelling/{core/bayesopt → bayesopt}/README.md +31 -13
- ins_pricing/modelling/{core/bayesopt → bayesopt}/__init__.py +64 -102
- ins_pricing/modelling/{core/bayesopt → bayesopt}/config_components.py +12 -0
- ins_pricing/modelling/{core/bayesopt → bayesopt}/config_preprocess.py +589 -552
- ins_pricing/modelling/{core/bayesopt → bayesopt}/core.py +987 -958
- ins_pricing/modelling/{core/bayesopt → bayesopt}/model_explain_mixin.py +296 -296
- ins_pricing/modelling/{core/bayesopt → bayesopt}/model_plotting_mixin.py +488 -548
- ins_pricing/modelling/{core/bayesopt → bayesopt}/models/__init__.py +27 -27
- ins_pricing/modelling/{core/bayesopt → bayesopt}/models/model_ft_components.py +349 -342
- ins_pricing/modelling/{core/bayesopt → bayesopt}/models/model_ft_trainer.py +921 -913
- ins_pricing/modelling/{core/bayesopt → bayesopt}/models/model_gnn.py +794 -785
- ins_pricing/modelling/{core/bayesopt → bayesopt}/models/model_resn.py +454 -446
- ins_pricing/modelling/bayesopt/trainers/__init__.py +19 -0
- ins_pricing/modelling/{core/bayesopt → bayesopt}/trainers/trainer_base.py +1294 -1282
- ins_pricing/modelling/{core/bayesopt → bayesopt}/trainers/trainer_ft.py +64 -56
- ins_pricing/modelling/{core/bayesopt → bayesopt}/trainers/trainer_glm.py +203 -198
- ins_pricing/modelling/{core/bayesopt → bayesopt}/trainers/trainer_gnn.py +333 -325
- ins_pricing/modelling/{core/bayesopt → bayesopt}/trainers/trainer_resn.py +279 -267
- ins_pricing/modelling/{core/bayesopt → bayesopt}/trainers/trainer_xgb.py +515 -313
- ins_pricing/modelling/bayesopt/utils/__init__.py +67 -0
- ins_pricing/modelling/bayesopt/utils/constants.py +21 -0
- ins_pricing/modelling/{core/bayesopt → bayesopt}/utils/distributed_utils.py +193 -186
- ins_pricing/modelling/bayesopt/utils/io_utils.py +7 -0
- ins_pricing/modelling/bayesopt/utils/losses.py +27 -0
- ins_pricing/modelling/bayesopt/utils/metrics_and_devices.py +17 -0
- ins_pricing/modelling/{core/bayesopt → bayesopt}/utils/torch_trainer_mixin.py +636 -623
- ins_pricing/modelling/{core/evaluation.py → evaluation.py} +113 -104
- ins_pricing/modelling/explain/__init__.py +55 -55
- ins_pricing/modelling/explain/metrics.py +27 -174
- ins_pricing/modelling/explain/permutation.py +237 -237
- ins_pricing/modelling/plotting/__init__.py +40 -36
- ins_pricing/modelling/plotting/compat.py +228 -0
- ins_pricing/modelling/plotting/curves.py +572 -572
- ins_pricing/modelling/plotting/diagnostics.py +163 -163
- ins_pricing/modelling/plotting/geo.py +362 -362
- ins_pricing/modelling/plotting/importance.py +121 -121
- ins_pricing/pricing/__init__.py +27 -27
- ins_pricing/pricing/factors.py +67 -56
- ins_pricing/production/__init__.py +35 -25
- ins_pricing/production/{predict.py → inference.py} +140 -57
- ins_pricing/production/monitoring.py +8 -21
- ins_pricing/reporting/__init__.py +11 -11
- ins_pricing/setup.py +1 -1
- ins_pricing/tests/production/test_inference.py +90 -0
- ins_pricing/utils/__init__.py +112 -78
- ins_pricing/utils/device.py +258 -237
- ins_pricing/utils/features.py +53 -0
- ins_pricing/utils/io.py +72 -0
- ins_pricing/utils/logging.py +34 -1
- ins_pricing/{modelling/core/bayesopt/utils → utils}/losses.py +125 -129
- ins_pricing/utils/metrics.py +158 -24
- ins_pricing/utils/numerics.py +76 -0
- ins_pricing/utils/paths.py +9 -1
- ins_pricing/utils/profiling.py +8 -4
- {ins_pricing-0.4.5.dist-info → ins_pricing-0.5.1.dist-info}/METADATA +1 -1
- ins_pricing-0.5.1.dist-info/RECORD +132 -0
- ins_pricing/modelling/core/BayesOpt.py +0 -146
- ins_pricing/modelling/core/__init__.py +0 -1
- ins_pricing/modelling/core/bayesopt/trainers/__init__.py +0 -19
- ins_pricing/modelling/core/bayesopt/utils/__init__.py +0 -86
- ins_pricing/modelling/core/bayesopt/utils/constants.py +0 -183
- ins_pricing/modelling/core/bayesopt/utils/io_utils.py +0 -126
- ins_pricing/modelling/core/bayesopt/utils/metrics_and_devices.py +0 -555
- ins_pricing/modelling/core/bayesopt/utils.py +0 -105
- ins_pricing/modelling/core/bayesopt/utils_backup.py +0 -1503
- ins_pricing/tests/production/test_predict.py +0 -233
- ins_pricing-0.4.5.dist-info/RECORD +0 -130
- {ins_pricing-0.4.5.dist-info → ins_pricing-0.5.1.dist-info}/WHEEL +0 -0
- {ins_pricing-0.4.5.dist-info → ins_pricing-0.5.1.dist-info}/top_level.txt +0 -0
ins_pricing/utils/__init__.py
CHANGED
|
@@ -1,83 +1,117 @@
|
|
|
1
|
-
"""Shared utilities for the ins_pricing package.
|
|
2
|
-
|
|
3
|
-
This module provides common utilities used across all submodules:
|
|
4
|
-
- Logging: Unified logging system with configurable levels
|
|
5
|
-
- Metrics: PSI calculation, model evaluation metrics
|
|
6
|
-
- Paths: Path resolution and data loading utilities
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
>>>
|
|
13
|
-
""
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"""Shared utilities for the ins_pricing package.
|
|
2
|
+
|
|
3
|
+
This module provides common utilities used across all submodules:
|
|
4
|
+
- Logging: Unified logging system with configurable levels
|
|
5
|
+
- Metrics: PSI calculation, model evaluation metrics
|
|
6
|
+
- Paths: Path resolution and data loading utilities
|
|
7
|
+
- IO: File helpers and parameter loading
|
|
8
|
+
- Numerics: EPS, tweedie loss, adaptive batch sizing
|
|
9
|
+
- Device: GPU/CPU device management for PyTorch models
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
>>> from ins_pricing.utils import get_logger, psi_report
|
|
13
|
+
>>> logger = get_logger("my_module")
|
|
14
|
+
>>> logger.info("Processing started")
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
# =============================================================================
|
|
18
20
|
# Logging utilities
|
|
19
21
|
# =============================================================================
|
|
20
|
-
from .logging import get_logger, configure_logging
|
|
21
|
-
|
|
22
|
-
# =============================================================================
|
|
23
|
-
# Metric utilities (PSI, model evaluation)
|
|
24
|
-
# =============================================================================
|
|
25
|
-
from .metrics import (
|
|
26
|
-
psi_numeric,
|
|
27
|
-
psi_categorical,
|
|
28
|
-
population_stability_index,
|
|
29
|
-
psi_report,
|
|
30
|
-
MetricFactory,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
# =============================================================================
|
|
34
|
-
#
|
|
35
|
-
# =============================================================================
|
|
36
|
-
from .
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# =============================================================================
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
22
|
+
from ins_pricing.utils.logging import get_logger, configure_logging, log_print
|
|
23
|
+
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# Metric utilities (PSI, model evaluation)
|
|
26
|
+
# =============================================================================
|
|
27
|
+
from ins_pricing.utils.metrics import (
|
|
28
|
+
psi_numeric,
|
|
29
|
+
psi_categorical,
|
|
30
|
+
population_stability_index,
|
|
31
|
+
psi_report,
|
|
32
|
+
MetricFactory,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# =============================================================================
|
|
36
|
+
# Numerical helpers
|
|
37
|
+
# =============================================================================
|
|
38
|
+
from ins_pricing.utils.numerics import (
|
|
39
|
+
EPS,
|
|
40
|
+
set_global_seed,
|
|
41
|
+
compute_batch_size,
|
|
42
|
+
tweedie_loss,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# =============================================================================
|
|
46
|
+
# Feature inference
|
|
47
|
+
# =============================================================================
|
|
48
|
+
from ins_pricing.utils.features import infer_factor_and_cate_list
|
|
49
|
+
|
|
50
|
+
# =============================================================================
|
|
51
|
+
# IO helpers
|
|
52
|
+
# =============================================================================
|
|
53
|
+
from ins_pricing.utils.io import IOUtils, csv_to_dict, ensure_parent_dir
|
|
54
|
+
|
|
55
|
+
# =============================================================================
|
|
56
|
+
# Path utilities
|
|
57
|
+
# =============================================================================
|
|
58
|
+
from ins_pricing.utils.paths import (
|
|
59
|
+
resolve_path,
|
|
60
|
+
resolve_dir_path,
|
|
61
|
+
resolve_data_path,
|
|
62
|
+
load_dataset,
|
|
63
|
+
coerce_dataset_types,
|
|
64
|
+
dedupe_preserve_order,
|
|
65
|
+
build_model_names,
|
|
66
|
+
parse_model_pairs,
|
|
67
|
+
fingerprint_file,
|
|
68
|
+
PLOT_MODEL_LABELS,
|
|
69
|
+
PYTORCH_TRAINERS,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# =============================================================================
|
|
73
|
+
# Device management (GPU/CPU)
|
|
74
|
+
# =============================================================================
|
|
75
|
+
from ins_pricing.utils.device import (
|
|
76
|
+
DeviceManager,
|
|
77
|
+
GPUMemoryManager,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
__all__ = [
|
|
59
81
|
# Logging
|
|
60
82
|
"get_logger",
|
|
61
83
|
"configure_logging",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
#
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
+
"log_print",
|
|
85
|
+
# Metrics
|
|
86
|
+
"psi_numeric",
|
|
87
|
+
"psi_categorical",
|
|
88
|
+
"population_stability_index",
|
|
89
|
+
"psi_report",
|
|
90
|
+
"MetricFactory",
|
|
91
|
+
# Numerics
|
|
92
|
+
"EPS",
|
|
93
|
+
"set_global_seed",
|
|
94
|
+
"compute_batch_size",
|
|
95
|
+
"tweedie_loss",
|
|
96
|
+
# Features
|
|
97
|
+
"infer_factor_and_cate_list",
|
|
98
|
+
# IO
|
|
99
|
+
"IOUtils",
|
|
100
|
+
"csv_to_dict",
|
|
101
|
+
"ensure_parent_dir",
|
|
102
|
+
# Paths
|
|
103
|
+
"resolve_path",
|
|
104
|
+
"resolve_dir_path",
|
|
105
|
+
"resolve_data_path",
|
|
106
|
+
"load_dataset",
|
|
107
|
+
"coerce_dataset_types",
|
|
108
|
+
"dedupe_preserve_order",
|
|
109
|
+
"build_model_names",
|
|
110
|
+
"parse_model_pairs",
|
|
111
|
+
"fingerprint_file",
|
|
112
|
+
"PLOT_MODEL_LABELS",
|
|
113
|
+
"PYTORCH_TRAINERS",
|
|
114
|
+
# Device
|
|
115
|
+
"DeviceManager",
|
|
116
|
+
"GPUMemoryManager",
|
|
117
|
+
]
|