A faster approximate alternative to scikit-learn GridSearchCV.
Project description
The algorithm works by creating a nested array of each possible choice of hyperparameters, organized by having each layer of the nested array change one of the numeric parameters while keeping the rest constant, with the most influential numeric parameter being changed first.
Ex: [[[[(0.001, 0.001, 1, 'linear', True, None), (0.001, 0.001, 1, 'linear', True, 'balanced'), (0.001, 0.001, 1, 'linear', False, None), ...]...]...], [[[(0.01, 0.001, 1, 'linear', True, None), (0.01, 0.001, 1, 'linear', True, 'balanced'), (0.01, 0.001, 1, 'linear', False, None), ...]...]...]...]
And so on down the list: [[[(0.001, 0.001, 1, 'linear', True, None), (0.001, 0.001, 1, 'linear', True, 'balanced'), (0.001, 0.001, 1, 'linear', False, None), ...], [(0.001, 0.01, 1, 'linear', True, None), (0.001, 0.01, 1, 'linear', True, 'balanced'), (0.001, 0.01, 1, 'linear', False, None), ...]...]...]
The algorithm then begins by iterating through the first entry of the top layer of the array (where only the most influential numeric hyperparameter is changing and all others are being held fixed) and finding which of the possible choices for this hyperparameter from the parameter grid achieves the best performance. If the performace fails to improve over several iterations, then we are in a "downward trend" (iterating away from the optimal value), and the loop is automatically closed to save time, reverting to the previous best performing model. Then, we set this hyperparameter fixed and enter the next layer of the nested array and continue the same process. When all numeric hyperparameters have been fixed, we perform a normal grid search over the non-numeric hyperparameters.
In order to reduce time spent searching for a better performing model after the current model plateaues (achieving roughly the same performance for each value after a certain point), we add a plateau threshold of 0.05. Each subsequent model must achieve performance better than the current best performing model by greater than the plateau threshold.
VALIDATION:
Example 1:
with regular GridSearchCV:
Accuracy (on training): 0.98
Accuracy (on testing): 1.0
Elapsed time: 264.8235182762146
with ReducedGridSearchCV:
Accuracy (on training): 0.95
Accuracy (on testing): 1.0
Elapsed time: 1.8074696063995361
Example 2:
with regular GridSearchCV:
Accuracy (on training): 0.912
Accuracy (on testing): 0.905
Elapsed time: 20.62173557281494
with ReducedGridSearchCV:
Accuracy (on training): 0.910
Accuracy (on testing): 0.92
Elapsed time: 10.864146947860718
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reduced_grid_search_cv-0.1.0.tar.gz.
File metadata
- Download URL: reduced_grid_search_cv-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fa3c5f92cb724f0d7e037d755f7a27b97faeffc27d0211101fd3e3fe9ac5009
|
|
| MD5 |
e31ba421f55fc1a3a10fcd26605e153d
|
|
| BLAKE2b-256 |
df70b4d0cf6b0348df0594a6a788821698f39edac7dbe04644b775d2705b25c6
|
File details
Details for the file reduced_grid_search_cv-0.1.0-py3-none-any.whl.
File metadata
- Download URL: reduced_grid_search_cv-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
260400ab51bda09473eaded88e6b424b142e82e7f0d746445ba05e76030a0904
|
|
| MD5 |
e7ec5faa0a8e1ee958816ebf8609986a
|
|
| BLAKE2b-256 |
422397dd121d761877abbbd5af8f4f389d9f595935152a1754a427c067c1516f
|