deskit 1.3__tar.gz → 1.3.2__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.
- {deskit-1.3/src/deskit.egg-info → deskit-1.3.2}/PKG-INFO +3 -1
- {deskit-1.3 → deskit-1.3.2}/README.md +2 -0
- {deskit-1.3 → deskit-1.3.2}/pyproject.toml +1 -1
- {deskit-1.3 → deskit-1.3.2}/src/deskit/base/knnbase.py +12 -3
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/lwsei.py +35 -1
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/lwseu.py +35 -1
- {deskit-1.3 → deskit-1.3.2/src/deskit.egg-info}/PKG-INFO +3 -1
- {deskit-1.3 → deskit-1.3.2}/LICENSE +0 -0
- {deskit-1.3 → deskit-1.3.2}/setup.cfg +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/__init__.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/_config.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/base/__init__.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/base/base.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/base/predictbase.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/__init__.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/dewsi.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/dewsiv.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/dewst.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/dewsu.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/dewsv.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/knorae.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/knoraiu.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/knorau.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/des/ola.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/metrics.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/neighbors.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/norms.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/router.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit/utils.py +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit.egg-info/SOURCES.txt +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit.egg-info/dependency_links.txt +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit.egg-info/requires.txt +0 -0
- {deskit-1.3 → deskit-1.3.2}/src/deskit.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deskit
|
|
3
|
-
Version: 1.3
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: A Python library for Dynamic Ensemble Selection
|
|
5
5
|
Author: Tikhon Vodyanov
|
|
6
6
|
License-Expression: MIT
|
|
@@ -251,6 +251,8 @@ router = DEWSU(task="regression", metric=pinball, mode="min", k=20)
|
|
|
251
251
|
|
|
252
252
|
Built-in metric strings: `accuracy`, `mae`, `mse`, `rmse`, `log_loss`, `prob_correct`.
|
|
253
253
|
|
|
254
|
+
Alternatively, pass `metric=None` and populate the dictionary passed to fit() with your own per-sample computed scores instead of predictions.
|
|
255
|
+
|
|
254
256
|
---
|
|
255
257
|
|
|
256
258
|
## Data types
|
|
@@ -220,6 +220,8 @@ router = DEWSU(task="regression", metric=pinball, mode="min", k=20)
|
|
|
220
220
|
|
|
221
221
|
Built-in metric strings: `accuracy`, `mae`, `mse`, `rmse`, `log_loss`, `prob_correct`.
|
|
222
222
|
|
|
223
|
+
Alternatively, pass `metric=None` and populate the dictionary passed to fit() with your own per-sample computed scores instead of predictions.
|
|
224
|
+
|
|
223
225
|
---
|
|
224
226
|
|
|
225
227
|
## Data types
|
|
@@ -49,12 +49,21 @@ class KNNBase(PredictBase, BaseRouter):
|
|
|
49
49
|
This method expects pre-validated numpy arrays.
|
|
50
50
|
"""
|
|
51
51
|
self.models = list(preds_dict.keys())
|
|
52
|
-
n_val
|
|
53
|
-
n_models
|
|
52
|
+
n_val = len(y)
|
|
53
|
+
n_models = len(self.models)
|
|
54
54
|
self.matrix = np.zeros((n_val, n_models))
|
|
55
55
|
|
|
56
56
|
for j, name in enumerate(self.models):
|
|
57
|
-
|
|
57
|
+
if self.metric is not None:
|
|
58
|
+
scores = self._compute_scores(y, preds_dict[name])
|
|
59
|
+
else:
|
|
60
|
+
scores = np.asarray(preds_dict[name])
|
|
61
|
+
# Validate shape
|
|
62
|
+
if scores.ndim != 1 or len(scores) != n_val:
|
|
63
|
+
raise ValueError(
|
|
64
|
+
f"Raw scores for model '{name}' must be a 1D array of length {n_val}; "
|
|
65
|
+
f"got shape {scores.shape}."
|
|
66
|
+
)
|
|
58
67
|
self.matrix[:, j] = scores if self.mode == 'max' else -scores
|
|
59
68
|
|
|
60
69
|
if self.task == 'classification':
|
|
@@ -3,6 +3,7 @@ LWSE-I: Locally Weighted Stacking Ensemble (Inverse-distance).
|
|
|
3
3
|
"""
|
|
4
4
|
from deskit.base.predictbase import PredictBase
|
|
5
5
|
from deskit._config import make_finder
|
|
6
|
+
from deskit.base.knnbase import _drop_self_match
|
|
6
7
|
from scipy.optimize import nnls
|
|
7
8
|
import numpy as np
|
|
8
9
|
|
|
@@ -77,6 +78,10 @@ class LWSEI(PredictBase):
|
|
|
77
78
|
self._y_val = y
|
|
78
79
|
self._finder.fit(features)
|
|
79
80
|
|
|
81
|
+
# Required for PredictBase.predict() when hard labels are used
|
|
82
|
+
if self.task == 'classification':
|
|
83
|
+
self.classes_ = np.unique(y)
|
|
84
|
+
|
|
80
85
|
def _weights_batch(self, x, temperature=None, k=None, loo=False, **kwargs):
|
|
81
86
|
"""
|
|
82
87
|
Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
|
|
@@ -127,4 +132,33 @@ class LWSEI(PredictBase):
|
|
|
127
132
|
total = coeffs.sum()
|
|
128
133
|
weights_out[b] = coeffs / total if total > 1e-10 else uniform
|
|
129
134
|
|
|
130
|
-
return weights_out
|
|
135
|
+
return weights_out
|
|
136
|
+
|
|
137
|
+
def _kneighbors(self, x, k=None, loo=False):
|
|
138
|
+
"""
|
|
139
|
+
Query the fitted neighbor index, with optional leave-one-out (LOO)
|
|
140
|
+
exclusion of each query point's own occurrence in the DSEL.
|
|
141
|
+
|
|
142
|
+
Parameters
|
|
143
|
+
----------
|
|
144
|
+
x : np.ndarray, shape (batch, n_features)
|
|
145
|
+
k : int, optional
|
|
146
|
+
Neighborhood size. None defers to the finder's default.
|
|
147
|
+
loo : bool
|
|
148
|
+
If True, query one extra neighbor per row and drop the
|
|
149
|
+
zero-distance match (the point itself) when present.
|
|
150
|
+
|
|
151
|
+
Returns
|
|
152
|
+
-------
|
|
153
|
+
distances, indices : np.ndarray, each shape (batch, k_eff)
|
|
154
|
+
"""
|
|
155
|
+
if not loo:
|
|
156
|
+
return self._finder.kneighbors(x, k=k)
|
|
157
|
+
|
|
158
|
+
# Resolve default k if not given
|
|
159
|
+
if k is None:
|
|
160
|
+
probe_distances, _ = self._finder.kneighbors(x, k=k)
|
|
161
|
+
k = probe_distances.shape[1]
|
|
162
|
+
|
|
163
|
+
distances, indices = self._finder.kneighbors(x, k=k + 1)
|
|
164
|
+
return _drop_self_match(distances, indices, k)
|
|
@@ -3,6 +3,7 @@ LWSE-U: Locally Weighted Stacking Ensemble (Uniform).
|
|
|
3
3
|
"""
|
|
4
4
|
from deskit.base.predictbase import PredictBase
|
|
5
5
|
from deskit._config import make_finder
|
|
6
|
+
from deskit.base.knnbase import _drop_self_match
|
|
6
7
|
from scipy.optimize import nnls
|
|
7
8
|
import numpy as np
|
|
8
9
|
|
|
@@ -77,6 +78,10 @@ class LWSEU(PredictBase):
|
|
|
77
78
|
self._y_val = y
|
|
78
79
|
self._finder.fit(features)
|
|
79
80
|
|
|
81
|
+
# Required for PredictBase.predict() when hard labels are used
|
|
82
|
+
if self.task == 'classification':
|
|
83
|
+
self.classes_ = np.unique(y)
|
|
84
|
+
|
|
80
85
|
def _weights_batch(self, x, temperature=None, k=None, loo=False, **kwargs):
|
|
81
86
|
"""
|
|
82
87
|
Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
|
|
@@ -119,4 +124,33 @@ class LWSEU(PredictBase):
|
|
|
119
124
|
total = coeffs.sum()
|
|
120
125
|
weights_out[b] = coeffs / total if total > 1e-10 else uniform
|
|
121
126
|
|
|
122
|
-
return weights_out
|
|
127
|
+
return weights_out
|
|
128
|
+
|
|
129
|
+
def _kneighbors(self, x, k=None, loo=False):
|
|
130
|
+
"""
|
|
131
|
+
Query the fitted neighbor index, with optional leave-one-out (LOO)
|
|
132
|
+
exclusion of each query point's own occurrence in the DSEL.
|
|
133
|
+
|
|
134
|
+
Parameters
|
|
135
|
+
----------
|
|
136
|
+
x : np.ndarray, shape (batch, n_features)
|
|
137
|
+
k : int, optional
|
|
138
|
+
Neighborhood size. None defers to the finder's default.
|
|
139
|
+
loo : bool
|
|
140
|
+
If True, query one extra neighbor per row and drop the
|
|
141
|
+
zero-distance match (the point itself) when present.
|
|
142
|
+
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
distances, indices : np.ndarray, each shape (batch, k_eff)
|
|
146
|
+
"""
|
|
147
|
+
if not loo:
|
|
148
|
+
return self._finder.kneighbors(x, k=k)
|
|
149
|
+
|
|
150
|
+
# Resolve default k if not given
|
|
151
|
+
if k is None:
|
|
152
|
+
probe_distances, _ = self._finder.kneighbors(x, k=k)
|
|
153
|
+
k = probe_distances.shape[1]
|
|
154
|
+
|
|
155
|
+
distances, indices = self._finder.kneighbors(x, k=k + 1)
|
|
156
|
+
return _drop_self_match(distances, indices, k)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deskit
|
|
3
|
-
Version: 1.3
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: A Python library for Dynamic Ensemble Selection
|
|
5
5
|
Author: Tikhon Vodyanov
|
|
6
6
|
License-Expression: MIT
|
|
@@ -251,6 +251,8 @@ router = DEWSU(task="regression", metric=pinball, mode="min", k=20)
|
|
|
251
251
|
|
|
252
252
|
Built-in metric strings: `accuracy`, `mae`, `mse`, `rmse`, `log_loss`, `prob_correct`.
|
|
253
253
|
|
|
254
|
+
Alternatively, pass `metric=None` and populate the dictionary passed to fit() with your own per-sample computed scores instead of predictions.
|
|
255
|
+
|
|
254
256
|
---
|
|
255
257
|
|
|
256
258
|
## Data types
|
|
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
|
|
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
|