LazyTune 🚀
Fast, smart, and lazy hyperparameter optimization
for scikit-learn models — up to 5–10× faster than GridSearchCV
with almost the same final performance.
Live Demo → https://lazytune.vercel.app
PyPI → https://pypi.org/project/lazytune/
🔥 Why LazyTune?
- 100% compatible with any scikit-learn-style estimator
- Works for classification & regression
- Supports all scikit-learn metrics + custom scorers
- Smart pipeline: screening → ranking → pruning → full training
- Early pruning of poor configurations (
prune_ratio) - Parallel execution (
n_jobs) - Clean trial summaries & rankings in pandas DataFrame
- Returns best model, params, score + detailed report
Installation
pip install lazytune
Quick Start
from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier
from lazytune import SmartSearch
X, y = load_breast_cancer(return_X_y=True)
param_grid = {
"n_estimators": [50, 100, 150, 200],
"max_depth": [5, 10, 15, None],
"min_samples_split": [2, 3, 4, 5]
}
search = SmartSearch(
estimator=RandomForestClassifier(random_state=42),
param_grid=param_grid,
metric="accuracy",
cv_folds=3,
prune_ratio=0.5, # keep top 50% after screening
n_jobs=-1 # use all cores
)
search.fit(X, y)
print("Best parameters:", search.best_params_)
print("Best CV score: ", search.best_score_)
print("\nBest model:\n", search.best_estimator_)
More Examples
SVM Classification
from sklearn.svm import SVC
from lazytune import SmartSearch
search = SmartSearch(
estimator=SVC(random_state=42),
param_grid={
"C": [0.1, 1, 10, 50, 100],
"kernel": ["linear", "rbf"],
"gamma": ["scale", "auto", 0.001, 0.0001]
},
metric="f1_macro",
cv_folds=5,
prune_ratio=0.6
)
Regression (Random Forest)
from sklearn.ensemble import RandomForestRegressor
from lazytune import SmartSearch
search = SmartSearch(
estimator=RandomForestRegressor(random_state=42),
param_grid={
"n_estimators": [100, 200, 300, 500],
"max_depth": [8, 12, 16, None],
"min_samples_split": [2, 4, 8]
},
metric="r2",
cv_folds=4,
n_jobs=-1
)
Supported Metrics (examples)
Classification
accuracy • f1 • f1_macro • f1_weighted • precision • recall • roc_auc • balanced_accuracy • ...
Regression
r2 • neg_mean_squared_error • neg_root_mean_squared_error • neg_mean_absolute_error • ...
Custom metrics → use sklearn.metrics.make_scorer
How LazyTune Works
- Generate all (or sampled) hyperparameter combinations
- Quick screening round with cross-validation
- Rank configurations by performance
- Prune bottom performers (
prune_ratio) - Train remaining promising candidates thoroughly
- Return best model + full trial summary
→ Much faster than GridSearchCV / RandomizedSearchCV
→ Usually very close (or identical) final performance
Main API – SmartSearch
Key Attributes
| Attribute | Description |
|---|---|
best_params_ |
Best hyperparameter dictionary |
best_score_ |
Best cross-validated score |
best_estimator_ |
Fully fitted estimator with best parameters |
summary_ |
pandas DataFrame with trial results & rankings |
cv_results_ |
Detailed CV results per candidate |
Main Methods
.fit(X, y).predict(X).score(X, y).get_params()/.set_params()
Requirements
- Python ≥ 3.8
- numpy
- pandas
- scikit-learn
Made with ❤️ by Anik Chand
MIT License
Feedback, issues, stars, and contributions are very welcome! 🌟
Try Live Demo • Install from PyPI
Happy tuning! 🚀
Metadata
Release files for lazytune 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lazytune-0.1.3.tar.gz | 10.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lazytune-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.5 kB
Release files / lazytune-0.1.3.tar.gz
| Download URL | lazytune-0.1.3.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32e51198eec96404f1f19a6ef5e72c0c0c34e841bb8013e8371a3ce1f8ad1f8a
|
|
BLAKE2b-256 checksum How to use checksums |
c7adca9bbd59a176a825cf189228f653520a718d5504d8a34e773462e466f123
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|
Release files / lazytune-0.1.3-py3-none-any.whl
| Download URL | lazytune-0.1.3-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebfc92bb2ec16a80d95b9b40ab68dd74797e77dce2ba27c23e58a0bc61ab897b
|
|
BLAKE2b-256 checksum How to use checksums |
bf76a6ebab41782ebedd358fbec6639d67bf63fbf40b1d26510ad713d3a65381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|