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/cli/Pricing_Run.py
CHANGED
|
@@ -1,25 +1,44 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import Optional
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
import importlib.util
|
|
6
|
+
import sys
|
|
7
|
+
|
|
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()
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
from ins_pricing.cli.utils.notebook_utils import run_from_config, run_from_config_cli # type: ignore
|
|
27
|
+
except Exception: # pragma: no cover
|
|
28
|
+
from utils.notebook_utils import run_from_config, run_from_config_cli # type: ignore
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def run(config_json: str | Path) -> None:
|
|
32
|
+
"""Unified entry point: run entry/incremental/watchdog/DDP based on config.json runner."""
|
|
33
|
+
run_from_config(config_json)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def main(argv: Optional[list[str]] = None) -> None:
|
|
37
|
+
run_from_config_cli(
|
|
38
|
+
"Pricing_Run: run BayesOpt by config.json (entry/incremental/watchdog/DDP).",
|
|
39
|
+
argv,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if __name__ == "__main__":
|
|
44
|
+
main()
|
|
@@ -11,13 +11,26 @@ Example:
|
|
|
11
11
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
|
-
from pathlib import Path
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
import importlib.util
|
|
16
|
+
import sys
|
|
17
|
+
|
|
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()
|
|
21
34
|
|
|
22
35
|
import argparse
|
|
23
36
|
import hashlib
|
|
@@ -30,8 +43,8 @@ import numpy as np
|
|
|
30
43
|
import pandas as pd
|
|
31
44
|
|
|
32
45
|
# Use unified import resolver to eliminate nested try/except chains
|
|
33
|
-
from .utils.import_resolver import resolve_imports, setup_sys_path
|
|
34
|
-
from .utils.evaluation_context import (
|
|
46
|
+
from ins_pricing.cli.utils.import_resolver import resolve_imports, setup_sys_path
|
|
47
|
+
from ins_pricing.cli.utils.evaluation_context import (
|
|
35
48
|
EvaluationContext,
|
|
36
49
|
TrainingContext,
|
|
37
50
|
ModelIdentity,
|
|
@@ -1112,10 +1125,21 @@ def train_from_config(args: argparse.Namespace) -> None:
|
|
|
1112
1125
|
output_override=args.output_dir,
|
|
1113
1126
|
)
|
|
1114
1127
|
output_dir = output_cfg["output_dir"]
|
|
1115
|
-
reuse_best_params = bool(
|
|
1116
|
-
args.reuse_best_params or runtime_cfg["reuse_best_params"])
|
|
1117
|
-
xgb_max_depth_max = runtime_cfg["xgb_max_depth_max"]
|
|
1118
|
-
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"]
|
|
1119
1143
|
optuna_storage = runtime_cfg["optuna_storage"]
|
|
1120
1144
|
optuna_study_prefix = runtime_cfg["optuna_study_prefix"]
|
|
1121
1145
|
best_params_files = runtime_cfg["best_params_files"]
|
|
@@ -1247,9 +1271,20 @@ def train_from_config(args: argparse.Namespace) -> None:
|
|
|
1247
1271
|
"use_ft_ddp": use_ft_ddp,
|
|
1248
1272
|
"use_gnn_ddp": use_gnn_ddp,
|
|
1249
1273
|
"output_dir": output_dir,
|
|
1250
|
-
"xgb_max_depth_max": xgb_max_depth_max,
|
|
1251
|
-
"xgb_n_estimators_max": xgb_n_estimators_max,
|
|
1252
|
-
"
|
|
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"),
|
|
1253
1288
|
"final_ensemble": bool(cfg.get("final_ensemble", False)),
|
|
1254
1289
|
"final_ensemble_k": int(cfg.get("final_ensemble_k", 3)),
|
|
1255
1290
|
"final_refit": bool(cfg.get("final_refit", True)),
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Bootstrap helpers for running CLI modules as scripts."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _find_repo_root(start: Optional[Path] = None) -> Path:
|
|
11
|
+
anchor = (start or Path(__file__)).resolve()
|
|
12
|
+
for parent in [anchor] + list(anchor.parents):
|
|
13
|
+
if (parent / "ins_pricing").is_dir():
|
|
14
|
+
return parent
|
|
15
|
+
return anchor.parent
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def ensure_repo_root(repo_root: Optional[Path] = None) -> Path:
|
|
19
|
+
"""Ensure the repository root (parent of ins_pricing/) is on sys.path."""
|
|
20
|
+
root = _find_repo_root(repo_root)
|
|
21
|
+
if str(root) not in sys.path:
|
|
22
|
+
sys.path.insert(0, str(root))
|
|
23
|
+
return root
|