da-stdk 0.1.0__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.
- da_stdk-0.1.0/PKG-INFO +145 -0
- da_stdk-0.1.0/README.md +119 -0
- da_stdk-0.1.0/da_stdk/__init__.py +5 -0
- da_stdk-0.1.0/da_stdk/dataio/__init__.py +25 -0
- da_stdk-0.1.0/da_stdk/dataio/kaust_loader.py +660 -0
- da_stdk-0.1.0/da_stdk/dataio/obs_sampling.py +84 -0
- da_stdk-0.1.0/da_stdk/dataio/splits.py +61 -0
- da_stdk-0.1.0/da_stdk/losses/__init__.py +34 -0
- da_stdk-0.1.0/da_stdk/losses/crps.py +180 -0
- da_stdk-0.1.0/da_stdk/losses/non_crossing.py +133 -0
- da_stdk-0.1.0/da_stdk/models/__init__.py +6 -0
- da_stdk-0.1.0/da_stdk/models/st_interp.py +928 -0
- da_stdk-0.1.0/da_stdk/training/__init__.py +7 -0
- da_stdk-0.1.0/da_stdk/training/config.py +160 -0
- da_stdk-0.1.0/da_stdk/training/trainer.py +480 -0
- da_stdk-0.1.0/da_stdk/utils/__init__.py +14 -0
- da_stdk-0.1.0/da_stdk/utils/conformal.py +171 -0
- da_stdk-0.1.0/da_stdk/utils/ema.py +105 -0
- da_stdk-0.1.0/da_stdk/utils/metrics.py +163 -0
- da_stdk-0.1.0/da_stdk/utils/seed.py +27 -0
- da_stdk-0.1.0/da_stdk/viz/__init__.py +52 -0
- da_stdk-0.1.0/da_stdk/viz/basis.py +242 -0
- da_stdk-0.1.0/da_stdk/viz/kaust_analysis.py +1011 -0
- da_stdk-0.1.0/da_stdk/viz/obs.py +120 -0
- da_stdk-0.1.0/da_stdk/viz/obs_density.py +133 -0
- da_stdk-0.1.0/da_stdk/viz/predictions.py +153 -0
- da_stdk-0.1.0/da_stdk/viz/spatial.py +324 -0
- da_stdk-0.1.0/da_stdk/viz/temporal.py +363 -0
- da_stdk-0.1.0/da_stdk/viz/training.py +63 -0
- da_stdk-0.1.0/pyproject.toml +125 -0
da_stdk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: da-stdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: DA-STDK: Data-adaptive spatio-temporal distributional prediction (cluster-adaptive bases, conformal calibration)
|
|
5
|
+
Author: Wen-Ting Wang
|
|
6
|
+
Author-email: egpivo@gmail.com
|
|
7
|
+
Requires-Python: >=3.10.13,<4.0.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Dist: joblib (>=1.3.0,<2.0.0)
|
|
14
|
+
Requires-Dist: k-means-constrained (>=0.7.3,<0.8.0)
|
|
15
|
+
Requires-Dist: matplotlib (>=3.7.0,<4.0.0)
|
|
16
|
+
Requires-Dist: numpy (>=1.24.0,<2.0.0)
|
|
17
|
+
Requires-Dist: pandas (>=2.0.0,<3.0.0)
|
|
18
|
+
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
19
|
+
Requires-Dist: scikit-learn (>=1.3.0,<2.0.0)
|
|
20
|
+
Requires-Dist: scipy (>=1.12.0,<2.0.0)
|
|
21
|
+
Requires-Dist: seaborn (>=0.13.0,<0.14.0)
|
|
22
|
+
Requires-Dist: torch (>=2.0.0,<3.0.0)
|
|
23
|
+
Requires-Dist: tqdm (>=4.65.0,<5.0.0)
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# DA-STDK
|
|
27
|
+
|
|
28
|
+
Reference implementation of **DA-STDK** for spatio-temporal distributional prediction, with a cluster-focused design. The method extends DeepKriging with cluster-adaptive spatial bases (learnable centers/scales) and cluster-aware conformal calibration for reliable prediction intervals under heterogeneous observation patterns. The current numerical-study pipeline targets the KAUST benchmark datasets (2a/2b).
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
### Prerequisites
|
|
33
|
+
|
|
34
|
+
- Conda (Miniconda or Anaconda)
|
|
35
|
+
- Poetry (will be installed automatically if not present)
|
|
36
|
+
|
|
37
|
+
### Installation
|
|
38
|
+
|
|
39
|
+
#### Option 1: Using Makefile (Recommended)
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Install project dependencies with Poetry
|
|
43
|
+
make install
|
|
44
|
+
|
|
45
|
+
# Install development dependencies in conda environment
|
|
46
|
+
make install-dev
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Option 2: Manual Setup
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Create and build conda environment
|
|
53
|
+
bash envs/conda/build_conda_env.sh
|
|
54
|
+
|
|
55
|
+
# Activate environment
|
|
56
|
+
conda activate st-dadk
|
|
57
|
+
|
|
58
|
+
# Install dependencies
|
|
59
|
+
poetry install --with dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Using as a library
|
|
63
|
+
|
|
64
|
+
Install in editable mode and import the `da_stdk` package:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install -e .
|
|
68
|
+
# or with poetry: poetry install
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import da_stdk
|
|
73
|
+
from da_stdk.models import STInterpMLP, create_model
|
|
74
|
+
from da_stdk.dataio.kaust_loader import load_kaust_csv_single
|
|
75
|
+
from da_stdk.viz import plot_training_curves, plot_observation_density_maps
|
|
76
|
+
# See da_stdk.viz.__all__, da_stdk.losses, da_stdk.training for full API
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Visualization (matplotlib, seaborn, `da_stdk.viz`) is included in the default install; no separate `[viz]` extra is required.
|
|
80
|
+
|
|
81
|
+
## Available Make Commands
|
|
82
|
+
|
|
83
|
+
- `make install`: Install project dependencies with Poetry
|
|
84
|
+
- `make install-dev`: Install development dependencies in conda environment
|
|
85
|
+
- `make test`: Run tests
|
|
86
|
+
- `make test-cov`: Run tests with coverage report
|
|
87
|
+
- `make lint`: Run linters (black, isort, mypy)
|
|
88
|
+
- `make format`: Format code with black and isort
|
|
89
|
+
- `make run-local-jupyter`: Start Jupyter Lab server
|
|
90
|
+
- `make table44`: Run KAUST experiment (all scenarios × models)
|
|
91
|
+
- `make clean`: Clean up temporary files
|
|
92
|
+
|
|
93
|
+
## Project Structure
|
|
94
|
+
|
|
95
|
+
- `da_stdk/`: Main package code
|
|
96
|
+
- `scripts/`: Training and analysis scripts
|
|
97
|
+
- `configs/`: Configuration files
|
|
98
|
+
- `data/`: Dataset files
|
|
99
|
+
- `envs/`: Environment setup scripts (conda and jupyter)
|
|
100
|
+
- `envs/.bin/`: Utility scripts
|
|
101
|
+
|
|
102
|
+
## Usage
|
|
103
|
+
|
|
104
|
+
### Training
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
python scripts/train_st_interp.py --config configs/config_st_interp.yaml
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### KAUST experiment (all scenarios × models)
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
python scripts/run_kaust_data.py --config configs/config_st_interp.yaml --n_experiments 10
|
|
114
|
+
python scripts/analyze_table_4_4.py --results_dir results/kaust_data_<timestamp>
|
|
115
|
+
```
|
|
116
|
+
Non-crossing λ is tuned via grid search (`scripts/grid_search_non_crossing_lambda.py`); pass `--non_crossing_lambda` to `run_kaust_data.py` for the chosen value.
|
|
117
|
+
|
|
118
|
+
### Jupyter Lab
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
make run-local-jupyter
|
|
122
|
+
# or
|
|
123
|
+
bash envs/jupyter/start_jupyter_lab.sh
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Troubleshooting
|
|
127
|
+
|
|
128
|
+
### Conda not found
|
|
129
|
+
|
|
130
|
+
Make sure Conda is installed and initialized in your shell:
|
|
131
|
+
```bash
|
|
132
|
+
conda init bash # or zsh
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Permission denied
|
|
136
|
+
|
|
137
|
+
Make shell scripts executable:
|
|
138
|
+
```bash
|
|
139
|
+
chmod +x envs/**/*.sh envs/.bin/*.sh
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Credit
|
|
143
|
+
|
|
144
|
+
This project builds on [**ST-DADK**](https://github.com/gystat/ST-DADK) (Spatio-Temporal Data-Adaptive DeepKriging) by [**gystat**](https://github.com/gystat). We thank the original repository for the base implementation.
|
|
145
|
+
|
da_stdk-0.1.0/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# DA-STDK
|
|
2
|
+
|
|
3
|
+
Reference implementation of **DA-STDK** for spatio-temporal distributional prediction, with a cluster-focused design. The method extends DeepKriging with cluster-adaptive spatial bases (learnable centers/scales) and cluster-aware conformal calibration for reliable prediction intervals under heterogeneous observation patterns. The current numerical-study pipeline targets the KAUST benchmark datasets (2a/2b).
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- Conda (Miniconda or Anaconda)
|
|
10
|
+
- Poetry (will be installed automatically if not present)
|
|
11
|
+
|
|
12
|
+
### Installation
|
|
13
|
+
|
|
14
|
+
#### Option 1: Using Makefile (Recommended)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Install project dependencies with Poetry
|
|
18
|
+
make install
|
|
19
|
+
|
|
20
|
+
# Install development dependencies in conda environment
|
|
21
|
+
make install-dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Option 2: Manual Setup
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Create and build conda environment
|
|
28
|
+
bash envs/conda/build_conda_env.sh
|
|
29
|
+
|
|
30
|
+
# Activate environment
|
|
31
|
+
conda activate st-dadk
|
|
32
|
+
|
|
33
|
+
# Install dependencies
|
|
34
|
+
poetry install --with dev
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### Using as a library
|
|
38
|
+
|
|
39
|
+
Install in editable mode and import the `da_stdk` package:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install -e .
|
|
43
|
+
# or with poetry: poetry install
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
import da_stdk
|
|
48
|
+
from da_stdk.models import STInterpMLP, create_model
|
|
49
|
+
from da_stdk.dataio.kaust_loader import load_kaust_csv_single
|
|
50
|
+
from da_stdk.viz import plot_training_curves, plot_observation_density_maps
|
|
51
|
+
# See da_stdk.viz.__all__, da_stdk.losses, da_stdk.training for full API
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Visualization (matplotlib, seaborn, `da_stdk.viz`) is included in the default install; no separate `[viz]` extra is required.
|
|
55
|
+
|
|
56
|
+
## Available Make Commands
|
|
57
|
+
|
|
58
|
+
- `make install`: Install project dependencies with Poetry
|
|
59
|
+
- `make install-dev`: Install development dependencies in conda environment
|
|
60
|
+
- `make test`: Run tests
|
|
61
|
+
- `make test-cov`: Run tests with coverage report
|
|
62
|
+
- `make lint`: Run linters (black, isort, mypy)
|
|
63
|
+
- `make format`: Format code with black and isort
|
|
64
|
+
- `make run-local-jupyter`: Start Jupyter Lab server
|
|
65
|
+
- `make table44`: Run KAUST experiment (all scenarios × models)
|
|
66
|
+
- `make clean`: Clean up temporary files
|
|
67
|
+
|
|
68
|
+
## Project Structure
|
|
69
|
+
|
|
70
|
+
- `da_stdk/`: Main package code
|
|
71
|
+
- `scripts/`: Training and analysis scripts
|
|
72
|
+
- `configs/`: Configuration files
|
|
73
|
+
- `data/`: Dataset files
|
|
74
|
+
- `envs/`: Environment setup scripts (conda and jupyter)
|
|
75
|
+
- `envs/.bin/`: Utility scripts
|
|
76
|
+
|
|
77
|
+
## Usage
|
|
78
|
+
|
|
79
|
+
### Training
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
python scripts/train_st_interp.py --config configs/config_st_interp.yaml
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### KAUST experiment (all scenarios × models)
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
python scripts/run_kaust_data.py --config configs/config_st_interp.yaml --n_experiments 10
|
|
89
|
+
python scripts/analyze_table_4_4.py --results_dir results/kaust_data_<timestamp>
|
|
90
|
+
```
|
|
91
|
+
Non-crossing λ is tuned via grid search (`scripts/grid_search_non_crossing_lambda.py`); pass `--non_crossing_lambda` to `run_kaust_data.py` for the chosen value.
|
|
92
|
+
|
|
93
|
+
### Jupyter Lab
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
make run-local-jupyter
|
|
97
|
+
# or
|
|
98
|
+
bash envs/jupyter/start_jupyter_lab.sh
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Troubleshooting
|
|
102
|
+
|
|
103
|
+
### Conda not found
|
|
104
|
+
|
|
105
|
+
Make sure Conda is installed and initialized in your shell:
|
|
106
|
+
```bash
|
|
107
|
+
conda init bash # or zsh
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Permission denied
|
|
111
|
+
|
|
112
|
+
Make shell scripts executable:
|
|
113
|
+
```bash
|
|
114
|
+
chmod +x envs/**/*.sh envs/.bin/*.sh
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Credit
|
|
118
|
+
|
|
119
|
+
This project builds on [**ST-DADK**](https://github.com/gystat/ST-DADK) (Spatio-Temporal Data-Adaptive DeepKriging) by [**gystat**](https://github.com/gystat). We thank the original repository for the base implementation.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Data I/O for STNF-XAttn
|
|
3
|
+
"""
|
|
4
|
+
from .kaust_loader import (
|
|
5
|
+
load_kaust_csv,
|
|
6
|
+
sample_observed_sites,
|
|
7
|
+
KAUSTWindowDataset,
|
|
8
|
+
create_dataloaders,
|
|
9
|
+
prepare_test_context,
|
|
10
|
+
predictions_to_csv
|
|
11
|
+
)
|
|
12
|
+
from .obs_sampling import create_spatial_obs_prob_fn, sample_observations
|
|
13
|
+
from .splits import split_train_valid
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
'load_kaust_csv',
|
|
17
|
+
'sample_observed_sites',
|
|
18
|
+
'KAUSTWindowDataset',
|
|
19
|
+
'create_dataloaders',
|
|
20
|
+
'prepare_test_context',
|
|
21
|
+
'predictions_to_csv',
|
|
22
|
+
'create_spatial_obs_prob_fn',
|
|
23
|
+
'sample_observations',
|
|
24
|
+
'split_train_valid',
|
|
25
|
+
]
|