edmkit 0.0.7__tar.gz → 0.0.9__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.
- {edmkit-0.0.7 → edmkit-0.0.9}/PKG-INFO +2 -2
- {edmkit-0.0.7 → edmkit-0.0.9}/pyproject.toml +2 -2
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/embedding.py +3 -6
- edmkit-0.0.9/src/edmkit/simplex_projection/knn.py +31 -0
- edmkit-0.0.7/src/edmkit/simplex_projection/knn.py +0 -40
- {edmkit-0.0.7 → edmkit-0.0.9}/README.md +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/ccm.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/generate/__init__.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/generate/double_pendulum.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/generate/lorenz.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/generate/mackey_glass.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/metrics.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/simplex_projection/__init__.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/simplex_projection/loo.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/simplex_projection/simplex_projection.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/smap.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/splits.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/types.py +0 -0
- {edmkit-0.0.7 → edmkit-0.0.9}/src/edmkit/util.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: edmkit
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.9
|
|
4
4
|
Summary: Simple EDM (Empirical Dynamic Modeling) library
|
|
5
5
|
Author: FUJISHIGE TEMMA
|
|
6
6
|
Author-email: FUJISHIGE TEMMA <tenma.x0@gmail.com>
|
|
7
|
+
Requires-Dist: kdtree-rs>=0.1.0
|
|
7
8
|
Requires-Dist: numpy>=2.4.3
|
|
8
9
|
Requires-Dist: scipy>=1.17.1
|
|
9
10
|
Requires-Dist: tinygrad>=0.11.0
|
|
10
|
-
Requires-Dist: usearch>=2.23.0
|
|
11
11
|
Requires-Python: >=3.13
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "edmkit"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.9"
|
|
4
4
|
description = "Simple EDM (Empirical Dynamic Modeling) library"
|
|
5
5
|
authors = [{ name = "FUJISHIGE TEMMA", email = "tenma.x0@gmail.com" }]
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
requires-python = ">= 3.13"
|
|
8
8
|
dependencies = [
|
|
9
|
+
"kdtree-rs>=0.1.0",
|
|
9
10
|
"numpy>=2.4.3",
|
|
10
11
|
"scipy>=1.17.1",
|
|
11
12
|
"tinygrad>=0.11.0",
|
|
12
|
-
"usearch>=2.23.0",
|
|
13
13
|
]
|
|
14
14
|
|
|
15
15
|
[dependency-groups]
|
|
@@ -77,7 +77,6 @@ def scan(
|
|
|
77
77
|
*,
|
|
78
78
|
E: list[int],
|
|
79
79
|
tau: list[int],
|
|
80
|
-
n_ahead: int = 1,
|
|
81
80
|
split: SplitFunc | None = None,
|
|
82
81
|
predict: PredictFunc | None = None,
|
|
83
82
|
metric: MetricFunc | None = None,
|
|
@@ -94,8 +93,6 @@ def scan(
|
|
|
94
93
|
Embedding dimension candidates.
|
|
95
94
|
tau : list[int]
|
|
96
95
|
Time delay candidates.
|
|
97
|
-
n_ahead : int
|
|
98
|
-
Prediction horizon (steps ahead).
|
|
99
96
|
split : SplitFunc or None
|
|
100
97
|
Callable ``(n: int) -> list[Fold]``. Defaults to sliding_folds.
|
|
101
98
|
predict : PredictFunc or None
|
|
@@ -138,15 +135,15 @@ def scan(
|
|
|
138
135
|
for e in E:
|
|
139
136
|
k = e + 1
|
|
140
137
|
max_lag = (e - 1) * tau_max
|
|
141
|
-
n_usable = N - max_lag
|
|
138
|
+
n_usable = N - max_lag
|
|
142
139
|
|
|
143
140
|
if n_usable < 2:
|
|
144
141
|
results.append(None)
|
|
145
142
|
continue
|
|
146
143
|
|
|
147
|
-
embeddings = [lagged_embed(x, t, e)[-
|
|
144
|
+
embeddings = [lagged_embed(x, t, e)[-n_usable:] for t in tau]
|
|
148
145
|
|
|
149
|
-
Y_aligned = Y[max_lag
|
|
146
|
+
Y_aligned = Y[max_lag:N]
|
|
150
147
|
|
|
151
148
|
folds = split(n_usable)
|
|
152
149
|
folds = [fold for fold in folds if len(fold.train) >= k] # ensure at least k points
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from kdtree import KDTree
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def knn(X: np.ndarray, Q: np.ndarray, k: int) -> tuple[np.ndarray, np.ndarray]:
|
|
6
|
+
"""Find the k-nearest neighbors of `Q` in `X` using `kdtree.KDTree`.
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
----------
|
|
10
|
+
X : np.ndarray
|
|
11
|
+
The input data (N, E)
|
|
12
|
+
Q : np.ndarray
|
|
13
|
+
The query points (M, E)
|
|
14
|
+
k : int
|
|
15
|
+
The number of nearest neighbors to find (typically E+1 for simplex projection).
|
|
16
|
+
|
|
17
|
+
Returns
|
|
18
|
+
-------
|
|
19
|
+
distances : np.ndarray
|
|
20
|
+
The distances from each query point in `Q` to its k nearest neighbors in `X` (M, k)
|
|
21
|
+
indices : np.ndarray
|
|
22
|
+
The indices of the k nearest neighbors in `X` for each query point in `Q` (M, k)
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
N = X.shape[0]
|
|
26
|
+
|
|
27
|
+
if N < k:
|
|
28
|
+
raise ValueError(f"Not enough points in X to find {k} neighbors, got N={N}")
|
|
29
|
+
|
|
30
|
+
tree = KDTree(X)
|
|
31
|
+
return tree.query(Q, k=k)
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from scipy.spatial import KDTree
|
|
3
|
-
from usearch.index import Index
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def knn(X: np.ndarray, Q: np.ndarray, k: int) -> tuple[np.ndarray, np.ndarray]:
|
|
7
|
-
"""Find the k-nearest neighbors of `Q` in `X` using either `usearch` or `scipy.spatial.KDTree` depending on the size and dimensionality of the data.
|
|
8
|
-
|
|
9
|
-
Parameters
|
|
10
|
-
----------
|
|
11
|
-
X : np.ndarray
|
|
12
|
-
The input data (N, E)
|
|
13
|
-
Q : np.ndarray
|
|
14
|
-
The query points (M, E)
|
|
15
|
-
k : int
|
|
16
|
-
The number of nearest neighbors to find (typically E+1 for simplex projection).
|
|
17
|
-
|
|
18
|
-
Returns
|
|
19
|
-
-------
|
|
20
|
-
distances : np.ndarray
|
|
21
|
-
The distances from each query point in `Q` to its k nearest neighbors in `X` (M, k)
|
|
22
|
-
indices : np.ndarray
|
|
23
|
-
The indices of the k nearest neighbors in `X` for each query point in `Q` (M, k)
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
N, E = X.shape
|
|
27
|
-
|
|
28
|
-
if N < k:
|
|
29
|
-
raise ValueError(f"Not enough points in X to find {k} neighbors, got N={N}")
|
|
30
|
-
|
|
31
|
-
if E >= 15 and N >= 10_000:
|
|
32
|
-
index = Index(ndim=E, metric="l2sq")
|
|
33
|
-
index.add(np.arange(len(X)), np.ascontiguousarray(X, dtype=np.float32))
|
|
34
|
-
matches = index.search(np.ascontiguousarray(Q, dtype=np.float32), k)
|
|
35
|
-
distances = np.atleast_2d(np.sqrt(np.asarray(matches.distances)))
|
|
36
|
-
indices = np.atleast_2d(np.asarray(matches.keys).astype(np.intp))
|
|
37
|
-
return distances, indices
|
|
38
|
-
else:
|
|
39
|
-
tree = KDTree(X)
|
|
40
|
-
return tree.query(Q, k=k)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|