deskit 1.2.1__tar.gz → 1.2.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 (32) hide show
  1. {deskit-1.2.1/src/deskit.egg-info → deskit-1.2.2}/PKG-INFO +1 -1
  2. {deskit-1.2.1 → deskit-1.2.2}/pyproject.toml +1 -1
  3. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/dewsi.py +2 -2
  4. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/dewsiv.py +2 -2
  5. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/dewst.py +5 -4
  6. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/dewsu.py +2 -2
  7. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/dewsv.py +2 -2
  8. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/knorae.py +2 -2
  9. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/knoraiu.py +2 -2
  10. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/knorau.py +2 -2
  11. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/lwsei.py +2 -2
  12. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/lwseu.py +2 -2
  13. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/ola.py +2 -2
  14. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/neighbors.py +0 -5
  15. {deskit-1.2.1 → deskit-1.2.2/src/deskit.egg-info}/PKG-INFO +1 -1
  16. {deskit-1.2.1 → deskit-1.2.2}/LICENSE +0 -0
  17. {deskit-1.2.1 → deskit-1.2.2}/README.md +0 -0
  18. {deskit-1.2.1 → deskit-1.2.2}/setup.cfg +0 -0
  19. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/__init__.py +0 -0
  20. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/_config.py +0 -0
  21. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/base/__init__.py +0 -0
  22. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/base/base.py +0 -0
  23. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/base/knnbase.py +0 -0
  24. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/base/predictbase.py +0 -0
  25. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/des/__init__.py +0 -0
  26. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/metrics.py +0 -0
  27. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/router.py +0 -0
  28. {deskit-1.2.1 → deskit-1.2.2}/src/deskit/utils.py +0 -0
  29. {deskit-1.2.1 → deskit-1.2.2}/src/deskit.egg-info/SOURCES.txt +0 -0
  30. {deskit-1.2.1 → deskit-1.2.2}/src/deskit.egg-info/dependency_links.txt +0 -0
  31. {deskit-1.2.1 → deskit-1.2.2}/src/deskit.egg-info/requires.txt +0 -0
  32. {deskit-1.2.1 → deskit-1.2.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.2.1
3
+ Version: 1.2.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.2.1"
7
+ version = "1.2.2"
8
8
  description = "A Python library for Dynamic Ensemble Selection"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -69,7 +69,7 @@ class DEWSI(KNNBase):
69
69
  )
70
70
  super().fit(features, y, preds_dict)
71
71
 
72
- def _weights_batch(self, x, temperature=None, threshold=None):
72
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None):
73
73
  """
74
74
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
75
75
  Returns (batch, n_models) weight array.
@@ -79,7 +79,7 @@ class DEWSI(KNNBase):
79
79
  (0.5 if self.mode == 'min' else 1.0))
80
80
  th = threshold if threshold is not None else self.threshold
81
81
 
82
- distances, indices = self.model.kneighbors(x) # both (batch, k)
82
+ distances, indices = self.model.kneighbors(x, k=k) # both (batch, k)
83
83
 
84
84
  # Inverse-distance-weighted average of each model's scores over K neighbors
85
85
  inv_dist = 1.0 / np.maximum(distances, 1e-8) # (batch, k)
@@ -84,7 +84,7 @@ class DEWSIV(KNNBase):
84
84
  preds = np.asarray(preds_dict[name])
85
85
  self._var_matrix[:, j] = np.vectorize(_signed_residual)(y, preds)
86
86
 
87
- def _weights_batch(self, x, temperature=None, threshold=None):
87
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None):
88
88
  """
89
89
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
90
90
  Returns (batch, n_models) weight array.
@@ -94,7 +94,7 @@ class DEWSIV(KNNBase):
94
94
  (0.5 if self.mode == 'min' else 1.0))
95
95
  th = threshold if threshold is not None else self.threshold
96
96
 
97
- distances, indices = self.model.kneighbors(x) # both (batch, k)
97
+ distances, indices = self.model.kneighbors(x, k=k) # both (batch, k)
98
98
 
99
99
  # Inverse-distance weights
100
100
  inv_dist = 1.0 / np.maximum(distances, 1e-8) # (batch, k)
@@ -86,7 +86,7 @@ class DEWST(KNNBase):
86
86
  )
87
87
  super().fit(features, y, preds_dict)
88
88
 
89
- def _weights_batch(self, x, temperature=None, threshold=None):
89
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None, r2_threshold=None):
90
90
  """
91
91
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
92
92
  Returns (batch, n_models) weight array.
@@ -94,9 +94,10 @@ class DEWST(KNNBase):
94
94
  t = temperature if temperature is not None else (
95
95
  self._temperature if self._temperature is not None else
96
96
  (0.5 if self._real_mode == 'min' else 1.0))
97
- th = threshold if threshold is not None else self.threshold
97
+ th = threshold if threshold is not None else self.threshold
98
+ r2_th = r2_threshold if r2_threshold is not None else self.r2_threshold
98
99
 
99
- distances, indices = self.model.kneighbors(x) # (batch, k)
100
+ distances, indices = self.model.kneighbors(x, k=k) # (batch, k)
100
101
  k = distances.shape[1]
101
102
 
102
103
  # Inverse-distance weights
@@ -157,7 +158,7 @@ class DEWST(KNNBase):
157
158
  trend_scores = intercept
158
159
 
159
160
  # Blend: trust trend where R² ≥ threshold, fall back otherwise
160
- use_trend = r2 >= self.r2_threshold
161
+ use_trend = r2 >= r2_th
161
162
  avg_scores = np.where(use_trend, trend_scores, dewsi_scores)
162
163
 
163
164
  # Standard DEWS softmax
@@ -65,7 +65,7 @@ class DEWSU(KNNBase):
65
65
  )
66
66
  super().fit(features, y, preds_dict)
67
67
 
68
- def _weights_batch(self, x, temperature=None, threshold=None):
68
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None):
69
69
  """
70
70
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
71
71
  Returns (batch, n_models) weight array.
@@ -75,7 +75,7 @@ class DEWSU(KNNBase):
75
75
  (0.5 if self.mode == 'min' else 1.0))
76
76
  th = threshold if threshold is not None else self.threshold
77
77
 
78
- _, indices = self.model.kneighbors(x) # (batch, k)
78
+ _, indices = self.model.kneighbors(x, k=k) # (batch, k)
79
79
 
80
80
  # Average each model's scores over the K neighbors
81
81
  avg_scores = self.matrix[indices].mean(axis=1) # (batch, n_models)
@@ -84,7 +84,7 @@ class DEWSV(KNNBase):
84
84
  preds = np.asarray(preds_dict[name])
85
85
  self._var_matrix[:, j] = np.vectorize(_signed_residual)(y, preds)
86
86
 
87
- def _weights_batch(self, x, temperature=None, threshold=None):
87
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None):
88
88
  """
89
89
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
90
90
  Returns (batch, n_models) weight array.
@@ -94,7 +94,7 @@ class DEWSV(KNNBase):
94
94
  (0.5 if self.mode == 'min' else 1.0))
95
95
  th = threshold if threshold is not None else self.threshold
96
96
 
97
- _, indices = self.model.kneighbors(x) # (batch, k)
97
+ _, indices = self.model.kneighbors(x, k=k) # (batch, k)
98
98
 
99
99
  # Uniform average of each model's scores over K neighbors
100
100
  neighbor_scores = self.matrix[indices] # (batch, k, n_models)
@@ -55,7 +55,7 @@ class KNORAE(KNNBase):
55
55
  )
56
56
  super().fit(features, y, preds_dict)
57
57
 
58
- def _weights_batch(self, x, temperature=None, threshold=None):
58
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None):
59
59
  """
60
60
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
61
61
  Returns (batch, n_models) weight array.
@@ -64,7 +64,7 @@ class KNORAE(KNNBase):
64
64
  th = threshold if threshold is not None else self.threshold
65
65
  n_models = len(self.models)
66
66
 
67
- _, indices = self.model.kneighbors(x)
67
+ _, indices = self.model.kneighbors(x, k=k)
68
68
  k = indices.shape[1]
69
69
  neighbor_scores = self.matrix[indices] # (batch, k, n_models)
70
70
 
@@ -56,7 +56,7 @@ class KNORAIU(KNNBase):
56
56
  )
57
57
  super().fit(features, y, preds_dict)
58
58
 
59
- def _weights_batch(self, x, temperature=None, threshold=None):
59
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None):
60
60
  """
61
61
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
62
62
  Returns (batch, n_models) weight array.
@@ -64,7 +64,7 @@ class KNORAIU(KNNBase):
64
64
  """
65
65
  th = threshold if threshold is not None else self.threshold
66
66
 
67
- distances, indices = self.model.kneighbors(x) # both (batch, k)
67
+ distances, indices = self.model.kneighbors(x, k=k) # both (batch, k)
68
68
  neighbor_scores = self.matrix[indices] # (batch, k, n_models)
69
69
 
70
70
  # Normalize per neighbor: best model = 1.0, worst = 0.0
@@ -56,7 +56,7 @@ class KNORAU(KNNBase):
56
56
  )
57
57
  super().fit(features, y, preds_dict)
58
58
 
59
- def _weights_batch(self, x, temperature=None, threshold=None):
59
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None):
60
60
  """
61
61
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
62
62
  Returns (batch, n_models) weight array.
@@ -64,7 +64,7 @@ class KNORAU(KNNBase):
64
64
  """
65
65
  th = threshold if threshold is not None else self.threshold
66
66
 
67
- _, indices = self.model.kneighbors(x)
67
+ _, indices = self.model.kneighbors(x, k=k)
68
68
  neighbor_scores = self.matrix[indices] # (batch, k, n_models)
69
69
 
70
70
  # Normalize per neighbor: best model = 1.0, worst = 0.0
@@ -74,7 +74,7 @@ class LWSEI(PredictBase):
74
74
  self._y_val = y
75
75
  self._finder.fit(features)
76
76
 
77
- def _weights_batch(self, x, temperature=None, **kwargs):
77
+ def _weights_batch(self, x, temperature=None, k=None, **kwargs):
78
78
  """
79
79
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
80
80
  Returns (batch, n_models) weight array.
@@ -87,7 +87,7 @@ class LWSEI(PredictBase):
87
87
  n_models = len(self.models)
88
88
  uniform = np.full(n_models, 1.0 / n_models)
89
89
 
90
- distances, indices = self._finder.kneighbors(x) # (batch, k)
90
+ distances, indices = self._finder.kneighbors(x, k=k) # (batch, k)
91
91
  weights_out = np.empty((batch_size, n_models))
92
92
 
93
93
  for b in range(batch_size):
@@ -74,7 +74,7 @@ class LWSEU(PredictBase):
74
74
  self._y_val = y
75
75
  self._finder.fit(features)
76
76
 
77
- def _weights_batch(self, x, temperature=None, **kwargs):
77
+ def _weights_batch(self, x, temperature=None, k=None, **kwargs):
78
78
  """
79
79
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
80
80
  Returns (batch, n_models) weight array.
@@ -87,7 +87,7 @@ class LWSEU(PredictBase):
87
87
  n_models = len(self.models)
88
88
  uniform = np.full(n_models, 1.0 / n_models)
89
89
 
90
- distances, indices = self._finder.kneighbors(x) # (batch, k)
90
+ distances, indices = self._finder.kneighbors(x, k=k) # (batch, k)
91
91
  weights_out = np.empty((batch_size, n_models))
92
92
 
93
93
  for b in range(batch_size):
@@ -54,7 +54,7 @@ class OLA(KNNBase):
54
54
  if mat_max > mat_min:
55
55
  self.matrix = (self.matrix - mat_min) / (mat_max - mat_min)
56
56
 
57
- def _weights_batch(self, x, temperature=None, threshold=None):
57
+ def _weights_batch(self, x, temperature=None, threshold=None, k=None):
58
58
  """
59
59
  Core weight computation. x is a 2-D float64 numpy array (batch, n_features).
60
60
  Returns (batch, n_models) weight array.
@@ -63,7 +63,7 @@ class OLA(KNNBase):
63
63
  """
64
64
  batch_size = x.shape[0]
65
65
 
66
- _, indices = self.model.kneighbors(x)
66
+ _, indices = self.model.kneighbors(x, k=k)
67
67
  avg_scores = self.matrix[indices].mean(axis=1) # (batch, n_models)
68
68
  best_indices = np.argmax(avg_scores, axis=1)
69
69
 
@@ -89,11 +89,6 @@ _NMSLIB_METRIC_MAP = {
89
89
  'dot': 'negdotprod',
90
90
  }
91
91
 
92
- # Unified view for HNSWNeighborFinder validation: union of both backends.
93
- # We keep the old name for backwards compatibility.
94
- _HNSW_METRIC_MAP = _HNSWLIB_METRIC_MAP # kept for any external references
95
- _HNSW_METRICS = _UNIVERSAL_METRICS # partial — see fit() for fallback note
96
-
97
92
  # All metrics callable from the public API.
98
93
  ALL_METRICS = _KNN_METRICS | {'jensenshannon', 'dot'}
99
94
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deskit
3
- Version: 1.2.1
3
+ Version: 1.2.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