pynnlf 0.2.2__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.
- pynnlf/__about__.py +1 -0
- pynnlf/__init__.py +5 -0
- pynnlf/api.py +17 -0
- pynnlf/discovery.py +63 -0
- pynnlf/engine.py +1238 -0
- pynnlf/hyperparams.py +38 -0
- pynnlf/model_utils.py +186 -0
- pynnlf/runner.py +108 -0
- pynnlf/scaffold/README_WORKSPACE.md +0 -0
- pynnlf/scaffold/data/README_data.md +40 -0
- pynnlf/scaffold/data/ds0_test.csv +4081 -0
- pynnlf/scaffold/models/README_models.md +61 -0
- pynnlf/scaffold/models/hyperparameters.yaml +264 -0
- pynnlf/scaffold/models/m10_rf.py +65 -0
- pynnlf/scaffold/models/m11_svr.py +53 -0
- pynnlf/scaffold/models/m12_rnn.py +152 -0
- pynnlf/scaffold/models/m13_lstm.py +208 -0
- pynnlf/scaffold/models/m14_gru.py +139 -0
- pynnlf/scaffold/models/m15_transformer.py +138 -0
- pynnlf/scaffold/models/m16_prophet.py +216 -0
- pynnlf/scaffold/models/m17_xgb.py +66 -0
- pynnlf/scaffold/models/m18_nbeats.py +107 -0
- pynnlf/scaffold/models/m1_naive.py +49 -0
- pynnlf/scaffold/models/m2_snaive.py +49 -0
- pynnlf/scaffold/models/m3_ets.py +133 -0
- pynnlf/scaffold/models/m4_arima.py +123 -0
- pynnlf/scaffold/models/m5_sarima.py +128 -0
- pynnlf/scaffold/models/m6_lr.py +76 -0
- pynnlf/scaffold/models/m7_ann.py +148 -0
- pynnlf/scaffold/models/m8_dnn.py +141 -0
- pynnlf/scaffold/models/m9_rt.py +74 -0
- pynnlf/scaffold/models/mXX_template.py +68 -0
- pynnlf/scaffold/specs/batch.yaml +4 -0
- pynnlf/scaffold/specs/experiment.yaml +4 -0
- pynnlf/scaffold/specs/pynnlf_config.yaml +69 -0
- pynnlf/scaffold/specs/testing_benchmark.csv +613 -0
- pynnlf/scaffold/specs/testing_benchmark_metadata.md +12 -0
- pynnlf/scaffold/specs/tests_ci.yaml +8 -0
- pynnlf/scaffold/specs/tests_full.yaml +23 -0
- pynnlf/tests_runner.py +211 -0
- pynnlf/tools/strip_notebook_artifacts.py +32 -0
- pynnlf/workspace.py +63 -0
- pynnlf/yamlio.py +28 -0
- pynnlf-0.2.2.dist-info/METADATA +168 -0
- pynnlf-0.2.2.dist-info/RECORD +47 -0
- pynnlf-0.2.2.dist-info/WHEEL +5 -0
- pynnlf-0.2.2.dist-info/top_level.txt +1 -0
pynnlf/__about__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.2"
|
pynnlf/__init__.py
ADDED
pynnlf/api.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Optional, Literal, Union
|
|
4
|
+
from .runner import run_single, run_batch
|
|
5
|
+
from .tests_runner import run_tests
|
|
6
|
+
|
|
7
|
+
PathLike = Union[str, Path]
|
|
8
|
+
TestMode = Literal["smoke", "full"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def run_experiment(spec_path: str | Path) -> None:
|
|
12
|
+
"""Run a single experiment from <workspace>/specs/experiment.yaml."""
|
|
13
|
+
run_single(spec_path)
|
|
14
|
+
|
|
15
|
+
def run_experiment_batch(spec_path: str | Path) -> None:
|
|
16
|
+
"""Run batch experiments from <workspace>/specs/batch.yaml."""
|
|
17
|
+
run_batch(spec_path)
|
pynnlf/discovery.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# coding: utf-8
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
def discover_unique_file(directory: Path, prefix: str, suffix: str):
|
|
7
|
+
"""
|
|
8
|
+
Discover a unique file in a directory by prefix and suffix.
|
|
9
|
+
|
|
10
|
+
Example:
|
|
11
|
+
prefix="m19" suffix=".py" matches: m19_*.py
|
|
12
|
+
prefix="ds19" suffix=".csv" matches: ds19_*.csv
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
directory (Path): Directory to search.
|
|
16
|
+
prefix (str): Required filename prefix (e.g. "m19" or "ds19").
|
|
17
|
+
suffix (str): Required suffix (e.g. ".py" or ".csv").
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
Path: The unique matching file path.
|
|
21
|
+
|
|
22
|
+
Raises:
|
|
23
|
+
FileNotFoundError: If no match found.
|
|
24
|
+
ValueError: If more than one match found.
|
|
25
|
+
"""
|
|
26
|
+
directory = Path(directory)
|
|
27
|
+
matches = sorted(directory.glob(f"{prefix}_*{suffix}"))
|
|
28
|
+
if len(matches) == 0:
|
|
29
|
+
# also allow exact name without underscore: ds19.csv / m19.py
|
|
30
|
+
exact = directory / f"{prefix}{suffix}"
|
|
31
|
+
if exact.exists():
|
|
32
|
+
return exact
|
|
33
|
+
raise FileNotFoundError(f"No file found for '{prefix}' in {directory}")
|
|
34
|
+
if len(matches) > 1:
|
|
35
|
+
raise ValueError(f"Multiple matches for '{prefix}' in {directory}: {[m.name for m in matches]}")
|
|
36
|
+
return matches[0]
|
|
37
|
+
|
|
38
|
+
def discover_model_name(models_dir: Path, model_id: str) -> str:
|
|
39
|
+
"""
|
|
40
|
+
Discover model file and return model_name (file stem).
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
models_dir (Path): <workspace>/models
|
|
44
|
+
model_id (str): model ID from spec, e.g. "m6" or "m19"
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
str: model_name file stem, e.g. "m6_lr" or "m19_my_model"
|
|
48
|
+
"""
|
|
49
|
+
p = discover_unique_file(models_dir, model_id, ".py")
|
|
50
|
+
return p.stem
|
|
51
|
+
|
|
52
|
+
def discover_dataset_path(data_dir: Path, dataset_id: str) -> Path:
|
|
53
|
+
"""
|
|
54
|
+
Discover dataset file path from dataset ID.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
data_dir (Path): <workspace>/data
|
|
58
|
+
dataset_id (str): dataset ID from spec, e.g. "ds0" or "ds19"
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
Path: dataset file path.
|
|
62
|
+
"""
|
|
63
|
+
return discover_unique_file(data_dir, dataset_id, ".csv")
|