deskit 1.3.1__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.
Files changed (33) hide show
  1. {deskit-1.3.1/src/deskit.egg-info → deskit-1.3.2}/PKG-INFO +1 -1
  2. {deskit-1.3.1 → deskit-1.3.2}/pyproject.toml +1 -1
  3. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/lwsei.py +35 -1
  4. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/lwseu.py +35 -1
  5. {deskit-1.3.1 → deskit-1.3.2/src/deskit.egg-info}/PKG-INFO +1 -1
  6. {deskit-1.3.1 → deskit-1.3.2}/LICENSE +0 -0
  7. {deskit-1.3.1 → deskit-1.3.2}/README.md +0 -0
  8. {deskit-1.3.1 → deskit-1.3.2}/setup.cfg +0 -0
  9. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/__init__.py +0 -0
  10. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/_config.py +0 -0
  11. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/base/__init__.py +0 -0
  12. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/base/base.py +0 -0
  13. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/base/knnbase.py +0 -0
  14. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/base/predictbase.py +0 -0
  15. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/__init__.py +0 -0
  16. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/dewsi.py +0 -0
  17. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/dewsiv.py +0 -0
  18. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/dewst.py +0 -0
  19. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/dewsu.py +0 -0
  20. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/dewsv.py +0 -0
  21. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/knorae.py +0 -0
  22. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/knoraiu.py +0 -0
  23. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/knorau.py +0 -0
  24. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/des/ola.py +0 -0
  25. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/metrics.py +0 -0
  26. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/neighbors.py +0 -0
  27. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/norms.py +0 -0
  28. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/router.py +0 -0
  29. {deskit-1.3.1 → deskit-1.3.2}/src/deskit/utils.py +0 -0
  30. {deskit-1.3.1 → deskit-1.3.2}/src/deskit.egg-info/SOURCES.txt +0 -0
  31. {deskit-1.3.1 → deskit-1.3.2}/src/deskit.egg-info/dependency_links.txt +0 -0
  32. {deskit-1.3.1 → deskit-1.3.2}/src/deskit.egg-info/requires.txt +0 -0
  33. {deskit-1.3.1 → 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.1
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "deskit"
7
- version = "1.3.1"
7
+ version = "1.3.2"
8
8
  description = "A Python library for Dynamic Ensemble Selection"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -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.1
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
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