Hypertune
Hypertune is a Python library designed to simplify hyperparameter optimization for machine learning models. It supports different search strategies, including Grid Search, Random Search, and Bayesian Optimization, to find the best hyperparameters for your model and improve its performance.
Features
- Grid Search: Exhaustively searches through a manually specified grid of hyperparameters.
- Random Search: Randomly samples hyperparameter combinations to find optimal settings.
- Bayesian Optimization: Uses probabilistic models to predict the best hyperparameters and minimize the number of trials needed.
Installation
You can install Hypertune using pip from PyPI:
pip install hypertune
Usage
Here’s how to use Hypertune with a machine learning model:
1. Import the library
from hypertune import Hypertune
from hypertune.grid_search import GridSearch
from hypertune.random_search import RandomSearch
from hypertune.bayesian_search import BayesianSearch
2. Define the model and parameters
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
# Load a dataset
X, y = load_iris(return_X_y=True)
# Define the model
model = RandomForestClassifier()
# Define hyperparameter search space for GridSearch
param_grid = {
'n_estimators': [50, 100, 200],
'max_depth': [None, 10, 20],
'min_samples_split': [2, 5, 10]
}
3. Run Grid Search
# Create the GridSearch object
grid_search = GridSearch(model, param_grid)
# Fit the model and find the best parameters
grid_search.fit(X, y)
# Get the best hyperparameters
print("Best Hyperparameters:", grid_search.best_params_)
4. Run Random Search
# Define the random search space
param_dist = {
'n_estimators': [50, 100, 200, 300],
'max_depth': [None, 10, 20, 30],
'min_samples_split': [2, 5, 10, 15]
}
# Create the RandomSearch object
random_search = RandomSearch(model, param_dist)
# Fit the model and find the best parameters
random_search.fit(X, y)
# Get the best hyperparameters
print("Best Hyperparameters:", random_search.best_params_)
5. Run Bayesian Optimization
# Define the hyperparameter search space for Bayesian Optimization
param_space = {
'n_estimators': (50, 200),
'max_depth': (1, 30),
'min_samples_split': (2, 15)
}
# Create the BayesianSearch object
bayesian_search = BayesianSearch(model, param_space)
# Fit the model and find the best parameters
bayesian_search.fit(X, y)
# Get the best hyperparameters
print("Best Hyperparameters:", bayesian_search.best_params_)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for hypertune-param 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hypertune_param-0.1.1.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hypertune_param-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / hypertune_param-0.1.1.tar.gz
| Download URL | hypertune_param-0.1.1.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a9814dbafa2816b7cf409860c435cbdc87a43900a65a19f6f636ab035a9b362
|
|
BLAKE2b-256 checksum How to use checksums |
df74ac76c45dd8f3e78e051785c42bd6eadd624f0c0ceabc717e64845b5650ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / hypertune_param-0.1.1-py3-none-any.whl
| Download URL | hypertune_param-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8b7f5e8eea8ed403cfb3e042c72fb37845180d5e6b0992d61c5187b1dda910a
|
|
BLAKE2b-256 checksum How to use checksums |
5e46f17e920216b8b1516eb2904de0ca6a5ec292e16d9127a9dd727b076197c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|