hyperparameter-optimizer 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
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.
- hyperparameter_optimizer/__init__.py +1 -1
- {hyperparameter_optimizer-0.2.0.dist-info → hyperparameter_optimizer-0.2.1.dist-info}/METADATA +19 -10
- hyperparameter_optimizer-0.2.1.dist-info/RECORD +7 -0
- hyperparameter_optimizer-0.2.0.dist-info/RECORD +0 -7
- {hyperparameter_optimizer-0.2.0.dist-info → hyperparameter_optimizer-0.2.1.dist-info}/WHEEL +0 -0
- {hyperparameter_optimizer-0.2.0.dist-info → hyperparameter_optimizer-0.2.1.dist-info}/licenses/LICENSE +0 -0
- {hyperparameter_optimizer-0.2.0.dist-info → hyperparameter_optimizer-0.2.1.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""A lightweight Python library for hyperparameter tuning using metaheuristic algorithms."""
|
|
2
2
|
from .core import HyperparameterOptimizer, KerasModel, TorchModel, SUPPORTED_SCORING
|
|
3
3
|
|
|
4
|
-
__version__ = "0.2.
|
|
4
|
+
__version__ = "0.2.1"
|
|
5
5
|
__all__ = ["HyperparameterOptimizer", "KerasModel", "TorchModel", "SUPPORTED_SCORING"]
|
{hyperparameter_optimizer-0.2.0.dist-info → hyperparameter_optimizer-0.2.1.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hyperparameter-optimizer
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: A lightweight Python library for hyperparameter tuning using Metaheuristic algorithms.
|
|
5
5
|
Author: Dr. Ahmed Moussa
|
|
6
6
|
License-Expression: MIT
|
|
@@ -44,13 +44,6 @@ Install from PyPI:
|
|
|
44
44
|
pip install hyperparameter-optimizer
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
With TensorFlow/Keras or PyTorch support:
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
pip install "hyperparameter-optimizer[tensorflow]"
|
|
51
|
-
pip install "hyperparameter-optimizer[torch]"
|
|
52
|
-
```
|
|
53
|
-
|
|
54
47
|
---
|
|
55
48
|
|
|
56
49
|
## ⚙️ Features
|
|
@@ -243,7 +236,8 @@ Wrap a function that **builds** the network in `KerasModel` or `TorchModel`. The
|
|
|
243
236
|
|
|
244
237
|
```python
|
|
245
238
|
import keras
|
|
246
|
-
from hyperparameter_optimizer import HyperparameterOptimizer
|
|
239
|
+
from hyperparameter_optimizer import HyperparameterOptimizer
|
|
240
|
+
from hyperparameter_optimizer.core import KerasModel
|
|
247
241
|
|
|
248
242
|
def build(units, dropout):
|
|
249
243
|
return keras.Sequential([
|
|
@@ -268,7 +262,8 @@ print(optimizer.best_params)
|
|
|
268
262
|
|
|
269
263
|
```python
|
|
270
264
|
from torch import nn
|
|
271
|
-
from hyperparameter_optimizer import HyperparameterOptimizer
|
|
265
|
+
from hyperparameter_optimizer import HyperparameterOptimizer
|
|
266
|
+
from hyperparameter_optimizer.core import TorchModel
|
|
272
267
|
|
|
273
268
|
def build(hidden, dropout):
|
|
274
269
|
return nn.Sequential(nn.Linear(X.shape[1], hidden), nn.ReLU(), nn.Dropout(dropout), nn.Linear(hidden, 3))
|
|
@@ -303,6 +298,13 @@ optimizer.optimizePSO(X, y, nParticles=8, bounds=[(1e-4, 1e-1), (1, 4)])
|
|
|
303
298
|
|
|
304
299
|
Pass several metrics in `scoring` and call `optimizeNSGA2`. One cross-validation run computes all of them, so extra objectives cost no extra training. The result is the **Pareto front**: the configurations where no metric can improve without another getting worse.
|
|
305
300
|
|
|
301
|
+
<p align="center">
|
|
302
|
+
<picture>
|
|
303
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/real-ahmed-moussa/hyperparameter_optimizer/main/imgs/pareto_front_dark.png">
|
|
304
|
+
<img src="https://raw.githubusercontent.com/real-ahmed-moussa/hyperparameter_optimizer/main/imgs/pareto_front_light.png" alt="NSGA-II Pareto front of precision vs. recall for a logistic regression tuned over C and its decision threshold" width="720">
|
|
305
|
+
</picture>
|
|
306
|
+
</p>
|
|
307
|
+
|
|
306
308
|
- `opt_type` can be one value for all metrics or a list, e.g. `["max", "min"]`.
|
|
307
309
|
- `"fit_time"` is a special objective: the mean training time per fold in seconds (always minimized unless `opt_type` is a list).
|
|
308
310
|
- The precision/recall trade-off is driven mostly by the decision **threshold**, so tune it too: wrap a Scikit-learn classifier in `FixedThresholdClassifier` (Scikit-learn ≥ 1.5), or tune `"threshold"` directly on `KerasModel`/`TorchModel`.
|
|
@@ -340,6 +342,13 @@ Accuracy against training time works the same way: `scoring=["accuracy", "fit_ti
|
|
|
340
342
|
|
|
341
343
|
This library leverages four optimization techniques—**Particle Swarm Optimization (PSO), Pattern Search (PS), a Genetic Algorithm (GA), and NSGA-II**—to explore the hyperparameter space effectively.
|
|
342
344
|
|
|
345
|
+
<p align="center">
|
|
346
|
+
<picture>
|
|
347
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/real-ahmed-moussa/hyperparameter_optimizer/main/imgs/optimizer_comparison_dark.png">
|
|
348
|
+
<img src="https://raw.githubusercontent.com/real-ahmed-moussa/hyperparameter_optimizer/main/imgs/optimizer_comparison_light.png" alt="Best cross-validation accuracy found by PSO, Pattern Search and the Genetic Algorithm while tuning an SVM, over 120 evaluations" width="720">
|
|
349
|
+
</picture>
|
|
350
|
+
</p>
|
|
351
|
+
|
|
343
352
|
Particle Swarm Optimization simulates a group of particles (candidate solutions) moving through the search space. Each particle adjusts its position based on its own best-known position and the best-known position among its peers, enabling a balance between exploration and exploitation as the swarm converges toward an optimal solution.
|
|
344
353
|
|
|
345
354
|
Pattern Search is a derivative-free method that explores the neighborhood of a current solution by systematically evaluating a set of search directions. If an improved solution is found, the algorithm moves in that direction and repeats the process, enabling efficient local refinement without relying on gradient information.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
hyperparameter_optimizer/__init__.py,sha256=lC_KBjfiUCKdGaJQpLw2XRbiJqxMmxHAT2qmv6Bjx1g,288
|
|
2
|
+
hyperparameter_optimizer/core.py,sha256=V_2Nw_qQrovJj-EJk6TT8gD6I3UmFXK0uMyYbvR4-wo,65816
|
|
3
|
+
hyperparameter_optimizer-0.2.1.dist-info/licenses/LICENSE,sha256=GFnq5v70zsLhnpPCseGip6sFkmjf3fMP1884JFp2QuI,1073
|
|
4
|
+
hyperparameter_optimizer-0.2.1.dist-info/METADATA,sha256=r101QQfgDT4cI3Es6zXOWVhJF77A5f8NNVSAHtj-4dU,20834
|
|
5
|
+
hyperparameter_optimizer-0.2.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
+
hyperparameter_optimizer-0.2.1.dist-info/top_level.txt,sha256=25Wd1D1OIdKZRL6FVRsMpb2Xja1dwS0JNh0ealHxwAY,25
|
|
7
|
+
hyperparameter_optimizer-0.2.1.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
hyperparameter_optimizer/__init__.py,sha256=c9PYN7d87M0r7cYd8iG_ZnrXBTe60nzuLU7Mtlnlw8Y,288
|
|
2
|
-
hyperparameter_optimizer/core.py,sha256=V_2Nw_qQrovJj-EJk6TT8gD6I3UmFXK0uMyYbvR4-wo,65816
|
|
3
|
-
hyperparameter_optimizer-0.2.0.dist-info/licenses/LICENSE,sha256=GFnq5v70zsLhnpPCseGip6sFkmjf3fMP1884JFp2QuI,1073
|
|
4
|
-
hyperparameter_optimizer-0.2.0.dist-info/METADATA,sha256=MPugt6HPorMPyUF7gIDFjN3Js40DmJisazSOB7S5rNo,19926
|
|
5
|
-
hyperparameter_optimizer-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
-
hyperparameter_optimizer-0.2.0.dist-info/top_level.txt,sha256=25Wd1D1OIdKZRL6FVRsMpb2Xja1dwS0JNh0ealHxwAY,25
|
|
7
|
-
hyperparameter_optimizer-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{hyperparameter_optimizer-0.2.0.dist-info → hyperparameter_optimizer-0.2.1.dist-info}/top_level.txt
RENAMED
|
File without changes
|